Add 'data' field to svg method for loading XML directly

Implements #65
This commit is contained in:
Andy Meneely
2015-04-29 16:49:38 -04:00
parent c42fbef8fa
commit e974880e03
12 changed files with 47 additions and 15 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ Squib::Deck.new do
text(str: embed_text, font: 'Sans 21',
x: 400, y: 320, width: 180, height: 300,
align: :center, ellipsize: false, justify: false, hint: :magenta) do |embed|
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
embed.svg key: ':tool:', width: 28, height: 28, data: File.read('spanner.svg')
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
end
+14
View File
@@ -17,6 +17,20 @@ Squib::Deck.new(width: 825, height: 1125, cards: 1) do
# Squib prepends a #-sign if one is not specified
svg file: 'spanner.svg', id: 'backdrop', x: 50, y: 450, width: 125, height: 125
# We can also load SVGs as a string of XML
svg data: File.read('spanner.svg'), x: 50, y: 600, width: 75, height: 75
# The svg data field works nicely with modifying the SVG XML on-the-fly.
# To run this one, do `gem install game_icons` and uncomment the following
#
# require 'game_icons'
# svg data: GameIcons.get('angler-fish').recolor(fg: '#ccc', bg: '#333').string,
# x: 150, y: 600, width: 75, height: 75
#
# More examples at https://github.com/andymeneely/game_icons
# (or `gem install game_icons`) to get & manipulate art from game-icons.net
# Nokogiri (already included in Squib) is also great for XML manipulation.
# WARNING! If you choose to use the SVG ID, the x-y coordinates are still
# relative to the SVG page. See this example in an SVG editor
svg file: 'offset.svg', id: 'thing', x: 0, y: 0, width: 600, height: 600