Class: Scruffy::Components::Grid
- Defined in:
- lib/scruffy/components/grid.rb
Instance Attribute Summary collapse
-
#markers ⇒ Object
Returns the value of attribute markers.
Attributes inherited from Base
#id, #options, #position, #size, #visible
Instance Method Summary collapse
Methods inherited from Base
#initialize, #process, #render
Constructor Details
This class inherits a constructor from Scruffy::Components::Base
Instance Attribute Details
#markers ⇒ Object
Returns the value of attribute markers.
4 5 6 |
# File 'lib/scruffy/components/grid.rb', line 4 def markers @markers end |
Instance Method Details
#draw(svg, bounds, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/scruffy/components/grid.rb', line 6 def draw(svg, bounds, ={}) markers = ([:markers] || self.markers) || 5 stroke_width = [:stroke_width] (0...markers).each do |idx| marker = ((1 / (markers - 1).to_f) * idx) * bounds[:height] svg.line(:x1 => 0, :y1 => marker, :x2 => bounds[:width], :y2 => marker, :style => "stroke: #{[:theme].marker.to_s}; stroke-width: #{stroke_width};") end end |