Class: ElementLine
- Inherits:
-
ElementSvg
- Object
- ElementSvg
- ElementLine
- Defined in:
- lib/render_svg3.rb
Instance Method Summary collapse
-
#initialize ⇒ ElementLine
constructor
A new instance of ElementLine.
- #invoke ⇒ Object
- #render_element ⇒ Object
Methods inherited from ElementSvg
#get_style_properties, #initialize_variables, #load_properties, #load_renderer, #parse_style, #scale, #scale=, #text, #text=, #x_offset, #x_offset=, #y_offset, #y_offset=
Constructor Details
#initialize ⇒ ElementLine
Returns a new instance of ElementLine.
143 144 145 146 147 148 149 |
# File 'lib/render_svg3.rb', line 143 def initialize() super local_properties = {'x1' => '','y1' => '', 'x2' => '', 'y2' => ''} @property.merge!(local_properties) @style_property = {'stroke' => '', 'stroke-width' => ''} @type = :line end |
Instance Method Details
#invoke ⇒ Object
151 152 153 154 |
# File 'lib/render_svg3.rb', line 151 def invoke() puts " -- render the 'line' element " + @text render_element() end |
#render_element ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/render_svg3.rb', line 156 def render_element() super do h = @property; hs = @style_property x1, y1, x2, y2 = h['x1'].to_i, h['y1'].to_i, h['x2'].to_i, h['y2'].to_i stroke_width = hs['stroke-width'].to_i colour = hs['stroke'] #scale = run_projectx('registry', 'get-key', :path => 'app/svg_viewer/scale').first.to_f x1, y1, x2, y2 = [x1, y1, x2, y2].map {|x| x * @@scale} x1, x2 = [x1, x2].map {|x| x + @@x_offset * @@scale} y1, y2 = [y1, y2].map {|x| x + @@y_offset * @@scale} stroke = {:width => stroke_width, :colour => colour} {:x1 => x1, :y1 => y1, :x2 => x2, :y2 => y2, :stroke => stroke} #draw properties end end |