Example of svg id being supplied, better input handling of svg ids
parent
9784d928d1
commit
b4702e1d4a
|
|
@ -30,6 +30,7 @@ module Squib
|
||||||
def svg(range: :all, file: nil, id: nil, x: 0, y: 0, width: :native, height: :native)
|
def svg(range: :all, file: nil, id: nil, x: 0, y: 0, width: :native, height: :native)
|
||||||
range = rangeify(range)
|
range = rangeify(range)
|
||||||
file = fileify(file)
|
file = fileify(file)
|
||||||
|
id = idify(id)
|
||||||
range.each{ |i| @cards[i].svg(file, id, x, y, width, height) }
|
range.each{ |i| @cards[i].svg(file, id, x, y, width, height) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,14 @@ module Squib
|
||||||
end
|
end
|
||||||
module_function :radiusify
|
module_function :radiusify
|
||||||
|
|
||||||
|
def idify(svgid)
|
||||||
|
unless svgid.nil?
|
||||||
|
svgid = '#' << svgid unless svgid.start_with? '#'
|
||||||
|
end
|
||||||
|
svgid
|
||||||
|
end
|
||||||
|
module_function :idify
|
||||||
|
|
||||||
def xyify
|
def xyify
|
||||||
#TODO: Allow negative numbers that subtract from the card width & height
|
#TODO: Allow negative numbers that subtract from the card width & height
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,10 @@ Squib::Deck.new(width: 825, height: 1125, cards: 1) do
|
||||||
# SVGs can be scaled too
|
# SVGs can be scaled too
|
||||||
svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
|
svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
|
||||||
|
|
||||||
|
# We can also limit our rendering to a single object, if the SVG ID is set
|
||||||
|
# Squib prepends a #-sign if one is not specified
|
||||||
|
svg file: 'spanner.svg', id: '#backdrop', x: 50, y: 350, width: 75, height: 75
|
||||||
|
svg file: 'spanner.svg', id: 'backdrop', x: 50, y: 450, width: 125, height: 125
|
||||||
|
|
||||||
save prefix: 'load_images_', format: :png
|
save prefix: 'load_images_', format: :png
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
viewBox="0 0 128 128"
|
viewBox="0 0 128 128"
|
||||||
id="svg2"
|
id="svg2"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
inkscape:version="0.48.4 r9939"
|
inkscape:version="0.48.3.1 r9886"
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
sodipodi:docname="spanner.svg">
|
sodipodi:docname="spanner.svg">
|
||||||
|
|
@ -36,15 +36,15 @@
|
||||||
guidetolerance="10"
|
guidetolerance="10"
|
||||||
inkscape:pageopacity="0"
|
inkscape:pageopacity="0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:window-width="1680"
|
inkscape:window-width="1280"
|
||||||
inkscape:window-height="988"
|
inkscape:window-height="1002"
|
||||||
id="namedview14"
|
id="namedview14"
|
||||||
showgrid="false"
|
showgrid="false"
|
||||||
inkscape:zoom="2.8284271"
|
inkscape:zoom="2.8284271"
|
||||||
inkscape:cx="98.928938"
|
inkscape:cx="98.928938"
|
||||||
inkscape:cy="62.194589"
|
inkscape:cy="62.194589"
|
||||||
inkscape:window-x="1432"
|
inkscape:window-x="1912"
|
||||||
inkscape:window-y="109"
|
inkscape:window-y="-8"
|
||||||
inkscape:window-maximized="1"
|
inkscape:window-maximized="1"
|
||||||
inkscape:current-layer="g3767"
|
inkscape:current-layer="g3767"
|
||||||
inkscape:document-units="in"
|
inkscape:document-units="in"
|
||||||
|
|
@ -60,8 +60,9 @@
|
||||||
x="5.3126979"
|
x="5.3126979"
|
||||||
height="501.3746"
|
height="501.3746"
|
||||||
width="501.3746"
|
width="501.3746"
|
||||||
id="rect3765"
|
id="backdrop"
|
||||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:10.62539577;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
|
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:10.62539577;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
||||||
|
inkscape:label="#rect3765" />
|
||||||
<path
|
<path
|
||||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||||
d="M 36.267098,-7.709219 C 16.393265,5.1318032 3.2161811,27.462365 3.2161811,52.884128 c 0,39.825874 32.2852369,72.111092 72.1110909,72.111092 23.870397,0 44.964938,-11.67699 58.089488,-29.545518 -11.26063,7.275808 -24.65607,11.517748 -39.060173,11.517748 -39.825853,0 -72.11109,-32.285221 -72.11109,-72.111095 0,-15.95546 5.248882,-30.6218942 14.021601,-42.565574 z"
|
d="M 36.267098,-7.709219 C 16.393265,5.1318032 3.2161811,27.462365 3.2161811,52.884128 c 0,39.825874 32.2852369,72.111092 72.1110909,72.111092 23.870397,0 44.964938,-11.67699 58.089488,-29.545518 -11.26063,7.275808 -24.65607,11.517748 -39.060173,11.517748 -39.825853,0 -72.11109,-32.285221 -72.11109,-72.111095 0,-15.95546 5.248882,-30.6218942 14.021601,-42.565574 z"
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.4 KiB |
Loading…
Reference in New Issue