Class: Scruffy::Layers::Area
Overview
Scruffy::Layers::Area
- Author
-
Brasten Sager
- Date
-
August 6th, 2006
Standard area graph.
Instance Attribute Summary
Attributes inherited from Base
#color, #complexity, #height, #max_value, #min_value, #opacity, #options, #outline, #points, #preferred_color, #preferred_outline, #relevant_data, #title, #width
Instance Method Summary collapse
-
#draw(svg, coords, options = {}) ⇒ Object
Render area graph.
Methods inherited from Base
#bottom_key, #bottom_value, #initialize, #legend_data, #relevant_data?, #render, #sum_values, #top_key, #top_value
Constructor Details
This class inherits a constructor from Scruffy::Layers::Base
Instance Method Details
#draw(svg, coords, options = {}) ⇒ Object
Render area graph.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/scruffy/layers/area.rb', line 11 def draw(svg, coords, ={}) # svg.polygon wants a long string of coords. points_value = "0,#{height} #{stringify_coords(coords).join(' ')} #{width},#{height}" # Experimental, for later user. # This was supposed to add some fun filters, 3d effects and whatnot. # Neither ImageMagick nor Mozilla SVG render this well (at all). Maybe a future thing. # # svg.defs { # svg.filter(:id => 'MyFilter', :filterUnits => 'userSpaceOnUse', :x => 0, :y => 0, :width => 200, :height => '120') { # svg.feGaussianBlur(:in => 'SourceAlpha', :stdDeviation => 4, :result => 'blur') # svg.feOffset(:in => 'blur', :dx => 4, :dy => 4, :result => 'offsetBlur') # svg.feSpecularLighting( :in => 'blur', :surfaceScale => 5, :specularConstant => '.75', # :specularExponent => 20, 'lighting-color' => '#bbbbbb', # :result => 'specOut') { # svg.fePointLight(:x => '-5000', :y => '-10000', :z => '20000') # } # # svg.feComposite(:in => 'specOut', :in2 => 'SourceAlpha', :operator => 'in', :result => 'specOut') # svg.feComposite(:in => 'sourceGraphic', :in2 => 'specOut', :operator => 'arithmetic', # :k1 => 0, :k2 => 1, :k3 => 1, :k4 => 0, :result => 'litPaint') # # svg.feMerge { # svg.feMergeNode(:in => 'offsetBlur') # svg.feMergeNode(:in => 'litPaint') # } # } # } svg.g(:transform => "translate(0, -#{relative(2)})") { svg.polygon(:points => points_value, :style => "fill: black; stroke: black; fill-opacity: 0.06; stroke-opacity: 0.06;") } svg.polygon(:points => points_value, :fill => color.to_s, :stroke => color.to_s, 'style' => "opacity: #{opacity}") end |