Class: SVGPlot::Gradient

Inherits:
ChildTag show all
Defined in:
lib/svgplot/gradient.rb

Overview

SVG base gradient element, with ruby methods to describe the gradient

Direct Known Subclasses

LinearGradient, RadialGradient

Instance Attribute Summary

Attributes inherited from ChildTag

#img

Attributes inherited from Tag

#attributes, #children, #defaults, #tag

Instance Method Summary collapse

Methods inherited from ChildTag

#initialize, #linear_gradient, #radial_gradient

Methods inherited from Tag

#append_child, #initialize, #method_missing, #path, #raw, #respond_to?, #spawn_child, #to_s, #use, #write

Methods included from Expansion

#expand

Methods included from Transform

#matrix, #rotate, #scale, #skew_x, #skew_y, #translate

Constructor Details

This class inherits a constructor from SVGPlot::ChildTag

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SVGPlot::Tag

Instance Method Details

#fillObject



5
6
7
# File 'lib/svgplot/gradient.rb', line 5

def fill
  "url(##{@attributes[:id]})"
end

#stop(offset, color, opacity) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/svgplot/gradient.rb', line 9

def stop(offset, color, opacity)
  append_child(
    ChildTag.new(
      @img,
      'stop',
      'offset' => offset,
      'stop-color' => color,
      'stop-opacity' => opacity
    )
  )
end