Class: DYI::Drawing::PenBase Abstract

Inherits:
Object
  • Object
show all
Extended by:
AttributeCreator
Defined in:
lib/dyi/drawing/pen.rb

Overview

This class is abstract.

A factory base class for createing a shape in the image.

PenBase object holds a Painting object and a Font object. Using these object, PenBase object creates instances of concrete subclass of Shape::Base; a created instance has a painting attribute and a font attribute that PenBase object holds.

This class has same attributes as Painting, these attributs access Painting object that PenBase object holds.

See Also:

Since:

  • 0.0.0

Direct Known Subclasses

Brush, Pen

Constant Summary collapse

DROP_SHADOW_OPTIONS =

Since:

  • 0.0.0

[:blur_std, :dx, :dy]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PenBase

Returns a new instance of PenBase.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :font (Font, Hash)

    the value of attribute font

  • :display (String)

    the value of attribute display; one of following values: "block", "none"

  • :fill (Color, #write_as)

    the value of attribute fill

  • :fill_opacity (#to_f)

    the value of attribute fill_opacity

  • :fill_rule (String)

    the value of attribute fill_rule; one of following values: "nonzero", "evenodd"

  • :opacity (#to_f)

    the value of attribute opacity

  • :stroke (Color, #write_as)

    the value of attribute stroke

  • :stroke_dasharray (Array<Length>, String)

    the value of attribute stroke_dasharray

  • :stroke_dashoffset (Length)

    the value of attribute stroke_dashoffset

  • :stroke_linecap (String)

    the value of attribute stroke_linecap; one of following values: "butt", "round", "square"

  • :stroke_linejoin (String)

    the value of attribute stroke_linejoin; one of following values: "miter", "round", "bevel"

  • :stroke_miterlimit (#to_f)

    the value of attribute stroke_miterlimit

  • :stroke_opacity (#to_f)

    the value of attribute stroke_opacity

  • :stroke_width (Length)

    the value of attribute stroke_width

  • :visible (String)

    the value of attribute visibility; one of following values: "visible", "hidden"

Since:

  • 0.0.0



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/dyi/drawing/pen.rb', line 52

def initialize(options={})
  @attributes = {}
  @painting = Painting.new
  options.each do |key, value|
    if key.to_sym == :font
      self.font = value
    elsif Painting::IMPLEMENT_ATTRIBUTES.include?(key)
      @painting.__send__("#{key}=", value)
    else
      @attributes[key] = value
    end
  end
end

Instance Attribute Details

#displayFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#drop_shadowObject

Since:

  • 0.0.0



48
49
50
# File 'lib/dyi/drawing/pen.rb', line 48

def drop_shadow
  @drop_shadow
end

#fillFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#fill_opacityFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#fill_ruleFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#opacityFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#strokeFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#stroke_dasharrayFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#stroke_dashoffsetFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#stroke_linecapFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#stroke_linejoinFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#stroke_miterlimitFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#stroke_opacityFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#stroke_widthFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

#visibilityFloat, ...

Returns or sets opacity of the paiting operation. Opacity of Both stroke and fill is set at the same time by this attribute. +++ Returns or sets the interior painting of the shape. +++ Returns or sets the opacity of the paiting operation used to paint the interior of the shape. +++ Returns or sets the rule which is to be used to detemine what parts of the canvas are included inside the shape. specifies one of the following values: "nonzero", "evenodd" +++ Returns or sets the painting along the outline of the shape. +++ Returns or sets the pattern of dashes and gaps used to stroke paths. +++ Returns or sets the distance into the dash pattern to start the dash. +++ Returns or sets the shape to be used at the end of open subpaths when they are stroked. specifies one of the following values: "butt", "round", "square" +++ Returns or sets the shape to be used at the corners of paths or basic shapes when they are stroked. specifies one of the following vlaues: "miter", "round", "bevel" +++ Returns or sets the limit value on the ratio of the miter length to the value of stroke_width attribute. When the ratio exceeds this attribute value, the join is converted from a miter to a bevel. +++ Returns or sets the opacity of the painting operation used to stroke. +++ Returns or sets the width of the stroke. +++ Returns or sets whether the shape is displayed. specifies one of the following vlaues: "block", "none" +++ Returns or sets whether the shape is hidden. specifies one of the following vlaues: "visible", "hidden"

Returns:

  • (Float)

    the value of attribute opacity

  • (Color, #write_as)

    the value of attribute fill

  • (Float)

    the value of attribute fill_opacity

  • (String)

    the value of attribute fill_rule

  • (Color, #write_as)

    the value of attribute stroke

  • (Array<Length>)

    the value of attribute stroke_dasharray

  • (Length)

    the value of attribute stroke_dashoffset

  • (String)

    the value of attribute stroke_linecap

  • (String)

    the value of attribute stroke_linejoin

  • (Float)

    the value of attribute stroke_mitterlimit

  • (Float)

    the value of attribute stroke_opacity

  • (Length)

    the value of attribute stroke_width

  • (String)

    the value of attribute display

  • (String)

    the value of attribute visibility

Since:

  • 1.0.0



134
135
136
137
138
139
140
# File 'lib/dyi/drawing/pen.rb', line 134

Painting::IMPLEMENT_ATTRIBUTES.each do |painting_attr|
  define_method(painting_attr) {| | @painting.__send__(painting_attr)}
  define_method("#{painting_attr}=".to_sym) {|value|
    @painting = @painting.clone
    @painting.__send__("#{painting_attr}=".to_sym, value)
  }
end

Instance Method Details

#draw_circle(canvas, center_point, radius, options = {}) ⇒ Shape::Circle

Draws a circle to specify the center point and the radius.

Parameters:

  • canvas (Element)

    the element which the circle is drawn on

  • center_point (Coordinate)

    the center point of the circle

  • radius (Length)

    the radius of the circle

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 0.0.0



340
341
342
# File 'lib/dyi/drawing/pen.rb', line 340

def draw_circle(canvas, center_point, radius, options={})
  Shape::Circle.create_on_center_radius(center_point, radius, merge_option(options)).draw_on(canvas)
end

#draw_closed_path(canvas, point, options = {}) {|path| ... } ⇒ Shape::Path

Draws a free-form line or curve, and closes path finally. See methods of Shape::Path for commands to draw the path.

Parameters:

  • canvas (Element)

    the element which the path is drawn on

  • point (Coordinate)

    the start point of the path

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Yields:

  • (path)

    a block which the path is drawn in

Yield Parameters:

Returns:

See Also:

Since:

  • 0.0.0



328
329
330
331
332
# File 'lib/dyi/drawing/pen.rb', line 328

def draw_closed_path(canvas, point, options={}, &block)
  path = draw_path(canvas, point, options, &block)
  path.close_path unless path.close?
  path
end

#draw_ellipse(canvas, center_point, radius_x, radius_y, options = {}) ⇒ Shape::Ellipse

Draws an ellipse to specify the center point and the radius.

Parameters:

  • canvas (Element)

    the element which the ellipse is drawn on

  • center_point (Coordinate)

    the center point of the ellipse

  • radius_x (Length)

    the x-axis radius of the ellipse

  • radius_y (Length)

    the y-axis radius of the ellipse

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 0.0.0



351
352
353
# File 'lib/dyi/drawing/pen.rb', line 351

def draw_ellipse(canvas, center_point, radius_x, radius_y, options={})
  Shape::Ellipse.create_on_center_radius(center_point, radius_x, radius_y, merge_option(options)).draw_on(canvas)
end

#draw_image(canvas, left_top_point, width, height, file_path, options = {}) ⇒ Shape::Image

Draws an image.

Parameters:

  • canvas (Element)

    the element which the image is drawn on

  • left_top (Coordinate)

    the left-top corner point of the image

  • width (Length)

    the width of the image

  • height (Length)

    the height of the image

  • file_path (String)

    the path of the image file

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :content_type (String)

    the content-type of the image

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 1.0.0



365
366
367
# File 'lib/dyi/drawing/pen.rb', line 365

def draw_image(canvas, left_top_point, width, height, file_path, options={})
  Shape::Image.new(left_top_point, width, height, file_path, merge_option(options)).draw_on(canvas)
end

#draw_line(canvas, start_point, end_point, options = {}) ⇒ Shape::Line Also known as: draw_line_on_start_end

Draws a line to specify the start and end points.

Parameters:

  • canvas (Element)

    the element which the line is drawn on

  • start_point (Coordinate)

    the start point of the line

  • end_point (Coordinate)

    the start point of the line

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 0.0.0



162
163
164
# File 'lib/dyi/drawing/pen.rb', line 162

def draw_line(canvas, start_point, end_point, options={})
  Shape::Line.create_on_start_end(start_point, end_point, merge_option(options)).draw_on(canvas)
end

#draw_line_on_direction(canvas, start_point, direction_x, direction_y, options = {}) ⇒ Shape::Line

Draws a line to specify the start points and the direction.

Parameters:

  • canvas (Element)

    the element which the line is drawn on

  • start_point (Coordinate)

    the start point of the line

  • direction_x (Length)

    the x-direction of the end point

  • direction_y (Length)

    the y-direction of the end point

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 0.0.0



175
176
177
# File 'lib/dyi/drawing/pen.rb', line 175

def draw_line_on_direction(canvas, start_point, direction_x, direction_y, options={})
  Shape::Line.create_on_direction(start_point, direction_x, direction_y, merge_option(options)).draw_on(canvas)
end

#draw_path(canvas, point, options = {}) {|path| ... } ⇒ Shape::Path

Draws free-form lines or curves. See methods of Shape::Path for commands to draw the path.

Parameters:

  • canvas (Element)

    the element which the path is drawn on

  • point (Coordinate)

    the start point of the path

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Yields:

  • (path)

    a block which the path is drawn in

Yield Parameters:

Returns:

See Also:

Since:

  • 0.0.0



314
315
316
317
318
# File 'lib/dyi/drawing/pen.rb', line 314

def draw_path(canvas, point, options={}, &block)
  path = Shape::Path.new(point, merge_option(options)).draw_on(canvas)
  yield path
  path
end

#draw_polygon(canvas, point, options = {}) {|polygon| ... } ⇒ Shape::Polygon #draw_polygon(canvas, points, options = {}) ⇒ Shape::Polygon

Draws a polygon.

Examples:

canvas = DYI::Canvas.new(100,100)
brush = DYI::Drawing::Brush.red_brush
brush.draw_polygon(canvas, [20, 20]) {|polygon|
  polygon.line_to([20, 80])
  polygon.line_to([80, 80])
}
# the following is the same processing
# brush.draw_polygon(canvas, [[20, 20], [20, 80], [80, 80]])

Overloads:

  • #draw_polygon(canvas, point, options = {}) {|polygon| ... } ⇒ Shape::Polygon

    Draws a polygon. Second and subsequent vertices are specified in the block.

    Parameters:

    • canvas (Element)

      the element which the polygon is drawn on

    • point (Coordinate)

      the first vertix of the polygon

    Options Hash (options):

    • :id (String)

      the ID of the drawn shape

    • :anchor_href (String)

      the location of a reference of a source anchor for the link of the drawn shape

    • :anchor_target (String)

      the relevant presentation context when the link is activated

    • :css_class (String)

      the CSS class attribute of the drawn shape

    Yields:

    • (polygon)

      a block which the polygon is drawn in

    Yield Parameters:

  • #draw_polygon(canvas, points, options = {}) ⇒ Shape::Polygon

    Draws a polygon to specify in the vertices.

    Parameters:

    • canvas (Element)

      the element which the polygon is drawn on

    • points (Array<Coordinate>)

      the array of the vertices

    Options Hash (options):

    • :id (String)

      the ID of the drawn shape

    • :anchor_href (String)

      the location of a reference of a source anchor for the link of the drawn shape

    • :anchor_target (String)

      the relevant presentation context when the link is activated

    • :css_class (String)

      the CSS class attribute of the drawn shape

    Since:

    • 1.1.0

Returns:

Since:

  • 0.0.0



264
265
266
267
268
269
270
271
272
273
# File 'lib/dyi/drawing/pen.rb', line 264

def draw_polygon(canvas, points, options={})
  if block_given?
    polygon = Shape::Polygon.new(points, merge_option(options))
    yield polygon
  else
    polygon = Shape::Polygon.new(points.first, merge_option(options))
    polygon.line_to(*points[1..-1])
  end
  polygon.draw_on(canvas)
end

#draw_polyline(canvas, point, options = {}) {|polyline| ... } ⇒ Shape::Polyline #draw_polyline(canvas, points, options = {}) ⇒ Shape::Polyline

Draws a polyline.

Examples:

canvas = DYI::Canvas.new(100,100)
pen = DYI::Drawing::Pen.black_pen
pen.draw_polyline(canvas, [20, 20]) {|polyline|
  polyline.line_to([20, 80])
  polyline.line_to([80, 80])
}
# the following is the same processing
# pen.draw_polyline(canvas, [[20, 20], [20, 80], [80, 80]])

Overloads:

  • #draw_polyline(canvas, point, options = {}) {|polyline| ... } ⇒ Shape::Polyline

    Draws a polyline. Second and subsequent making-up points are specified in the block.

    Parameters:

    • canvas (Element)

      the element which the polyline is drawn on

    • point (Coordinate)

      the start point of the polyline

    Options Hash (options):

    • :id (String)

      the ID of the drawn shape

    • :anchor_href (String)

      the location of a reference of a source anchor for the link of the drawn shape

    • :anchor_target (String)

      the relevant presentation context when the link is activated

    • :css_class (String)

      the CSS class attribute of the drawn shape

    Yields:

    • (polyline)

      a block which the polyline is drawn in

    Yield Parameters:

  • #draw_polyline(canvas, points, options = {}) ⇒ Shape::Polyline

    Draws a polyline to specify in the making-up points.

    Parameters:

    • canvas (Element)

      the element which the polyline is drawn on

    • points (Array<Coordinate>)

      the array of the making-up points

    Options Hash (options):

    • :id (String)

      the ID of the drawn shape

    • :anchor_href (String)

      the location of a reference of a source anchor for the link of the drawn shape

    • :anchor_target (String)

      the relevant presentation context when the link is activated

    • :css_class (String)

      the CSS class attribute of the drawn shape

    Since:

    • 1.1.0

Returns:

Since:

  • 0.0.0



216
217
218
219
220
221
222
223
224
225
# File 'lib/dyi/drawing/pen.rb', line 216

def draw_polyline(canvas, points, options={})
  if block_given?
    polyline = Shape::Polyline.new(points, merge_option(options))
    yield polyline
  else
    polyline = Shape::Polyline.new(points.first, merge_option(options))
    polyline.line_to(*points[1..-1])
  end
  polyline.draw_on(canvas)
end

#draw_rectangle(canvas, left_top_point, width, height, options = {}) ⇒ Shape::Rectangle Also known as: draw_rectangle_on_width_height

Draws a rectangle to specify the left-top points, the width and the height.

Parameters:

  • canvas (Element)

    the element which the rectangle is drawn on

  • left_top (Coordinate)

    the left-top corner point of the rectangle

  • width (Length)

    the width of the rectangle

  • height (Length)

    the height of the rectangle

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :rx (Length)

    for rounded rectangles, the x-axis radius of the ellipse used to round off the corners of the rectangle

  • :ry (Length)

    for rounded rectangles, the y-axis radius of the ellipse used to round off the corners of the rectangle

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 0.0.0



287
288
289
# File 'lib/dyi/drawing/pen.rb', line 287

def draw_rectangle(canvas, left_top_point, width, height, options={})
  Shape::Rectangle.create_on_width_height(left_top_point, width, height, merge_option(options)).draw_on(canvas)
end

#draw_rectangle_on_corner(canvas, top, right, bottom, left, options = {}) ⇒ Shape::Rectangle

Draws a rectangle to specify the top, right, botton and left cooridinate.

Parameters:

  • canvas (Element)

    the element which the rectangle is drawn on

  • top (Length)

    the y-coordinate of the top of the rectangle

  • right (Length)

    the x-coordinate of the right of the rectangle

  • bottom (Length)

    the y-coordinate of the bottom of the rectangle

  • left (Length)

    the x-coordinate of the left of the rectangle

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :rx (Length)

    for rounded rectangles, the x-axis radius of the ellipse used to round off the corners of the rectangle

  • :ry (Length)

    for rounded rectangles, the y-axis radius of the ellipse used to round off the corners of the rectangle

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 0.0.0



301
302
303
# File 'lib/dyi/drawing/pen.rb', line 301

def draw_rectangle_on_corner(canvas, top, right, bottom, left, options={})
  Shape::Rectangle.create_on_corner(top, right, bottom, left, merge_option(options)).draw_on(canvas)
end

#draw_sector(canvas, center_point, radius_x, radius_y, start_angle, center_angle, options = {}) ⇒ Shape::Path

Draws a circular sector.

Parameters:

  • canvas (Element)

    the element which the sector is drawn on

  • center_point (Coordinate)

    the center point of the sector

  • radius_x (Length)

    the x-axis radius of the sector

  • radius_y (Length)

    the y-axis radius of the sector

  • start_angle (Number)

    the starting-radius angle of the sector from x-direction in degrees

  • center_angle (Number)

    the center angle of the sector from the starting-radius in degrees

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :inner_radius (#to_f)

    if you want to make a concentric hole with sector, the ratio of the hole’s radius to the sector radius

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Raises:

  • (ArgumentError)

    :inner_radius option is out of range

Since:

  • 0.0.0



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/dyi/drawing/pen.rb', line 396

def draw_sector(canvas, center_point, radius_x, radius_y, start_angle, center_angle, options={})
  start_angle = (center_angle > 0 ? start_angle : (start_angle + center_angle)) % 360
  center_angle = center_angle.abs
  options = merge_option(options)
  inner_radius = options.delete(:inner_radius).to_f
  center_point = Coordinate.new(center_point)
  radius_x = Length.new(radius_x).abs
  radius_y = Length.new(radius_y).abs
  large_arc = (center_angle.abs > 180)

  if inner_radius >= 1 || 0 > inner_radius
    raise ArgumentError, "inner_radius option is out of range: #{inner_radius}"
  end
  if 360 <= center_angle
    if inner_radius == 0.0
      draw_ellipse(canvas, center_point, radius_x, radius_y, options)
    else
      draw_toroid(canvas, center_point, radius_x, radius_y, inner_radius, options)
    end
  else
    arc_start_pt = Coordinate.new(
        radius_x * DYI::Util.cos(start_angle),
        radius_y * DYI::Util.sin(start_angle)) + center_point
    arc_end_pt = Coordinate.new(
        radius_x * DYI::Util.cos(start_angle + center_angle),
        radius_y * DYI::Util.sin(start_angle + center_angle)) + center_point

    draw_sector_internal(canvas, center_point,
                         radius_x, radius_y, inner_radius,
                         arc_start_pt, arc_end_pt,
                         start_angle, center_angle, options)
  end
end

#draw_text(canvas, point, text, options = {}) ⇒ Shape::Text

Draws a text.

Parameters:

  • canvas (Element)

    the element which the text is drawn on

  • point (Coordinate)

    the point of the base-line of the text. See :text_anchor option

  • text (String)

    the drawn text string

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :text_anchor (String)

    the way of aligning a string of text relative to point argument. specifies one of the following vlaues: "start", "middle", "end"

  • :text_length (Length)

    the length of the displayed text

  • :length_adjust (String)

    the way of adjustments to make the rendered length of the text match text_length option. specifies one of the following vlaues: "spacing", "spacingAndGlyphs"

  • :text_decoration (String)

    the decorations that are added to the text. specifies a string in a comma-separated combination of the following vlaues: "underline", "overline", "line-through", "blink"

  • :writing_mode (String)

    the inline-progression-direction for a text. specifies one of the following vlaues: "lr-tb", "rl-tb", "tb-rl", "lr", "rl", "tb"

  • :show_border (Boolean)

    whether the border is shown

  • :border_rx (Length)

    the x-axis radius of the ellipse used to round off the corners of the rectangle when the rounded border is shown

  • :vertical_padding (Length)

    the interval of vertical border line and text area

  • :horizontal_padding (Length)

    the interval of horizontal border line and text area

  • :border_ry (Length)

    the y-axis radius of the ellipse used to round off the corners of the rectangle when the rounded border is shown

  • :background_color (Color, #write_as)

    the interior painting of the border-line when the border is shown

  • :border_color (Color, #write_as)

    the painting along the border-line when the border is shown

  • :border_width (Length)

    the width of border-line when the border is shown

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 0.0.0



505
506
507
# File 'lib/dyi/drawing/pen.rb', line 505

def draw_text(canvas, point, text, options={})
  Shape::Text.new(point, text, merge_option(options)).draw_on(canvas)
end

#draw_toroid(canvas, center_point, radius_x, radius_y, inner_radius, options = {}) ⇒ Shape::Path

Draws a toroid.

Parameters:

  • canvas (Element)

    the element which the toroid is drawn on

  • center_point (Coordinate)

    the center point of the toroid

  • radius_x (Length)

    the x-axis radius of the toroid

  • radius_y (Length)

    the y-axis radius of the toroid

  • inner_radius (#to_f)

    the ratio of inner radius to the sector radius

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Raises:

  • (ArgumentError)

    inner_radius is out of range

Since:

  • 1.1.0



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/dyi/drawing/pen.rb', line 441

def draw_toroid(canvas, center_point, radius_x, radius_y, inner_radius, options={})
  if inner_radius >= 1 || 0 > inner_radius
    raise ArgumentError, "inner_radius is out of range: #{inner_radius}"
  end
  radius_x, radius_y = Length.new(radius_x).abs, Length.new(radius_y).abs
  center_point = Coordinate.new(center_point)
  arc_start_pt = center_point + [radius_x, 0]
  arc_opposite_pt = center_point - [radius_x, 0]
  inner_arc_start_pt = center_point + [radius_x * inner_radius, 0]
  inner_arc_opposite_pt = center_point - [radius_x * inner_radius, 0]

  draw_closed_path(canvas, arc_start_pt, options) {|path|
    path.arc_to(arc_opposite_pt, radius_x, radius_y, 0, true)
    path.arc_to(arc_start_pt, radius_x, radius_y, 0, true)
    path.close_path
    path.move_to(inner_arc_start_pt)
    path.arc_to(inner_arc_opposite_pt,
                radius_x * inner_radius,
                radius_y * inner_radius, 0, true, false)
    path.arc_to(inner_arc_start_pt,
                radius_x * inner_radius,
                radius_y * inner_radius, 0, true, false)
  }
end

#import_image(canvas, left_top_point, width, height, image_uri, options = {}) ⇒ Shape::ImageReference

Adds a reference to an image.

Parameters:

  • canvas (Element)

    the element which the reference is added on

  • left_top (Coordinate)

    the left-top corner point of the image

  • width (Length)

    the width of the image

  • height (Length)

    the height of the image

  • image_uri (String)

    the reference URI to the image file

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    the ID of the drawn shape

  • :anchor_href (String)

    the location of a reference of a source anchor for the link of the drawn shape

  • :anchor_target (String)

    the relevant presentation context when the link is activated

  • :css_class (String)

    the CSS class attribute of the drawn shape

Returns:

Since:

  • 1.0.0



378
379
380
# File 'lib/dyi/drawing/pen.rb', line 378

def import_image(canvas, left_top_point, width, height, image_uri, options={})
  Shape::ImageReference.new(left_top_point, width, height, image_uri, merge_option(options)).draw_on(canvas)
end