Class: XRVG::Shape
Overview
To provide a set of services a shape class must provide
Direct Known Subclasses
Instance Method Summary collapse
-
#contour(*args) ⇒ Object
must return the contour of the shape, of Curve type.
-
#default_style ⇒ Object
return the default style for a Shape instance.
-
#size ⇒ Object
compute size of the shape, from viewbox.
-
#surface ⇒ Object
compute the “surface” of the viewbox of the shape.
-
#svg ⇒ Object
must return the svg description of the shape.
-
#viewbox ⇒ Object
must return the enclosing box of the shape, that is [xmin, ymin, xmax, ymax].
Methods included from Attributable
Instance Method Details
#contour(*args) ⇒ Object
must return the contour of the shape, of Curve type
abstract
not yet used
24 25 26 |
# File 'lib/shape.rb', line 24 def contour( *args ) raise NotImplementedError.new("#{self.class.name}#contour is an abstract method.") end |
#default_style ⇒ Object
return the default style for a Shape instance
is done on instance, because for Curve for example, strokewidth is proportional to length
55 56 57 |
# File 'lib/shape.rb', line 55 def default_style() return Style[:fill, Color.black ] end |
#size ⇒ Object
compute size of the shape, from viewbox
47 48 49 50 |
# File 'lib/shape.rb', line 47 def size() xmin, ymin, xmax, ymax = self.viewbox return [xmax-xmin, ymax-ymin] end |
#surface ⇒ Object
compute the “surface” of the viewbox of the shape
use size method
62 63 64 65 |
# File 'lib/shape.rb', line 62 def surface width, height = self.size return width * height end |
#svg ⇒ Object
must return the svg description of the shape
abstract
must be defined
33 34 35 |
# File 'lib/shape.rb', line 33 def svg() raise NotImplementedError.new("#{self.class.name}#svg is an abstract method.") end |
#viewbox ⇒ Object
must return the enclosing box of the shape, that is [xmin, ymin, xmax, ymax]
abstract
must be defined
42 43 44 |
# File 'lib/shape.rb', line 42 def viewbox() raise NotImplementedError.new("#{self.class.name}#viewbox is an abstract method.") end |