class SvgDrawer::Path
Public Class Methods
new(path_components, params = {})
click to toggle source
Calls superclass method
SvgDrawer::Base::new
# File lib/svg_drawer/path.rb, line 20 def initialize(path_components, params = {}) @components = path_components super(params) end
Public Instance Methods
height()
click to toggle source
# File lib/svg_drawer/path.rb, line 29 def height @height ||= height_unscaled * param(:scale).to_d end
height_unscaled()
click to toggle source
# File lib/svg_drawer/path.rb, line 37 def height_unscaled @height_unscaled ||= param(:img_height).to_d end
incomplete()
click to toggle source
# File lib/svg_drawer/path.rb, line 41 def incomplete false end
width()
click to toggle source
# File lib/svg_drawer/path.rb, line 25 def width @width ||= width_unscaled * param(:scale).to_d end
width_unscaled()
click to toggle source
# File lib/svg_drawer/path.rb, line 33 def width_unscaled @width_unscaled ||= param(:img_width).to_d end
Private Instance Methods
_draw(parent)
click to toggle source
# File lib/svg_drawer/path.rb, line 61 def _draw(parent) style = {} style[:fill] = param(:fill) style[:stroke] = param(:stroke) x = param(:x_reposition) ? (viewport_width / 2 - width_unscaled * autoscale / 2) / param(:scale) : 0 y = param(:y_reposition) ? (viewport_height / 2 - height_unscaled * autoscale / 2) / param(:scale) : 0 Utils::RasemWrapper.group(parent, class: 'path') do |path_group| @components.each { |path| path_group.path(d: path, style: style) } end.scale(param(:scale), param(:scale)).translate(x, y) end
autoscale()
click to toggle source
This scale comes from preserveAspectRatio which can't be disabled (librsvg crashes with OOM when preserveAspectRatio=“none”)
# File lib/svg_drawer/path.rb, line 57 def autoscale [width / param(:img_width), height / param(:img_height)].min end
viewport_height()
click to toggle source
# File lib/svg_drawer/path.rb, line 51 def viewport_height param(:height) || height end
viewport_width()
click to toggle source
# File lib/svg_drawer/path.rb, line 47 def viewport_width param(:width) || width end