Module: MapPrint::PngHandlers::Texts
- Included in:
- LegendHandler, MapPrint::PngHandler, ScalebarHandler
- Defined in:
- lib/map_print/png_handlers/texts.rb
Instance Method Summary collapse
- #draw_text(png, text, position, options) ⇒ Object
- #print_texts(texts, png) ⇒ Object
- #sanitize_options(options) ⇒ Object
Instance Method Details
#draw_text(png, text, position, options) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/map_print/png_handlers/texts.rb', line 12 def draw_text(png, text, position, ) png. do |c| c.density 300 ().each do |option, value| c.send option, value end c.draw "text #{position} '#{text}'" end end |
#print_texts(texts, png) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/map_print/png_handlers/texts.rb', line 4 def print_texts(texts, png) (texts || []).each do |text| position = "#{text[:position][:x]},#{text[:position][:y]}" draw_text(png, text[:text], position, text[:options]) end end |
#sanitize_options(options) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/map_print/png_handlers/texts.rb', line 22 def () return {} unless .is_a?(Hash) [:stroke] = .delete :color if [:color] [:fill] = .delete :fill_color if [:fill_color] [:gravity] ||= 'NorthWest' [:font] ||= 'Arial' end |