Class: DYI::Drawing::PenBase Abstract
- Inherits:
-
Object
- Object
- DYI::Drawing::PenBase
- Extended by:
- AttributeCreator
- Defined in:
- lib/dyi/drawing/pen.rb
Overview
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.
Constant Summary collapse
- DROP_SHADOW_OPTIONS =
[:blur_std, :dx, :dy]
Instance Attribute Summary collapse
-
#display ⇒ Float, ...
Returns or sets opacity of the paiting operation.
- #drop_shadow ⇒ Object
-
#fill ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#fill_opacity ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#fill_rule ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#opacity ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#stroke ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#stroke_dasharray ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#stroke_dashoffset ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#stroke_linecap ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#stroke_linejoin ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#stroke_miterlimit ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#stroke_opacity ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#stroke_width ⇒ Float, ...
Returns or sets opacity of the paiting operation.
-
#visibility ⇒ Float, ...
Returns or sets opacity of the paiting operation.
Instance Method Summary collapse
-
#draw_circle(canvas, center_point, radius, options = {}) ⇒ Shape::Circle
Draws a circle to specify the center point and the radius.
-
#draw_closed_path(canvas, point, options = {}) {|path| ... } ⇒ Shape::Path
Draws a free-form line or curve, and closes path finally.
-
#draw_ellipse(canvas, center_point, radius_x, radius_y, options = {}) ⇒ Shape::Ellipse
Draws an ellipse to specify the center point and the radius.
-
#draw_image(canvas, left_top_point, width, height, file_path, options = {}) ⇒ Shape::Image
Draws an image.
-
#draw_line(canvas, start_point, end_point, options = {}) ⇒ Shape::Line
(also: #draw_line_on_start_end)
Draws a line to specify the start and end points.
-
#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.
-
#draw_path(canvas, point, options = {}) {|path| ... } ⇒ Shape::Path
Draws free-form lines or curves.
-
#draw_polygon(canvas, points, options = {}) ⇒ Shape::Polygon
Draws a polygon.
-
#draw_polyline(canvas, points, options = {}) ⇒ Shape::Polyline
Draws a polyline.
-
#draw_rectangle(canvas, left_top_point, width, height, options = {}) ⇒ Shape::Rectangle
(also: #draw_rectangle_on_width_height)
Draws a rectangle to specify the left-top points, the width and the height.
-
#draw_rectangle_on_corner(canvas, top, right, bottom, left, options = {}) ⇒ Shape::Rectangle
Draws a rectangle to specify the top, right, botton and left cooridinate.
-
#draw_sector(canvas, center_point, radius_x, radius_y, start_angle, center_angle, options = {}) ⇒ Shape::Path
Draws a circular sector.
-
#draw_text(canvas, point, text, options = {}) ⇒ Shape::Text
Draws a text.
-
#draw_toroid(canvas, center_point, radius_x, radius_y, inner_radius, options = {}) ⇒ Shape::Path
Draws a toroid.
-
#import_image(canvas, left_top_point, width, height, image_uri, options = {}) ⇒ Shape::ImageReference
Adds a reference to an image.
-
#initialize(options = {}) ⇒ PenBase
constructor
A new instance of PenBase.
Constructor Details
#initialize(options = {}) ⇒ PenBase
Returns a new instance of PenBase.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dyi/drawing/pen.rb', line 52 def initialize(={}) @attributes = {} @painting = Painting.new .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
#display ⇒ Float, ...
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"
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_shadow ⇒ Object
48 49 50 |
# File 'lib/dyi/drawing/pen.rb', line 48 def drop_shadow @drop_shadow end |
#fill ⇒ Float, ...
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"
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_opacity ⇒ Float, ...
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"
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_rule ⇒ Float, ...
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"
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 |
#opacity ⇒ Float, ...
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"
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 ⇒ Float, ...
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"
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_dasharray ⇒ Float, ...
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"
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_dashoffset ⇒ Float, ...
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"
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_linecap ⇒ Float, ...
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"
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_linejoin ⇒ Float, ...
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"
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_miterlimit ⇒ Float, ...
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"
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_opacity ⇒ Float, ...
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"
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_width ⇒ Float, ...
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"
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 |
#visibility ⇒ Float, ...
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"
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.
340 341 342 |
# File 'lib/dyi/drawing/pen.rb', line 340 def draw_circle(canvas, center_point, radius, ={}) Shape::Circle.create_on_center_radius(center_point, radius, merge_option()).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.
328 329 330 331 332 |
# File 'lib/dyi/drawing/pen.rb', line 328 def draw_closed_path(canvas, point, ={}, &block) path = draw_path(canvas, point, , &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.
351 352 353 |
# File 'lib/dyi/drawing/pen.rb', line 351 def draw_ellipse(canvas, center_point, radius_x, radius_y, ={}) Shape::Ellipse.create_on_center_radius(center_point, radius_x, radius_y, merge_option()).draw_on(canvas) end |
#draw_image(canvas, left_top_point, width, height, file_path, options = {}) ⇒ Shape::Image
Draws an image.
365 366 367 |
# File 'lib/dyi/drawing/pen.rb', line 365 def draw_image(canvas, left_top_point, width, height, file_path, ={}) Shape::Image.new(left_top_point, width, height, file_path, merge_option()).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.
162 163 164 |
# File 'lib/dyi/drawing/pen.rb', line 162 def draw_line(canvas, start_point, end_point, ={}) Shape::Line.create_on_start_end(start_point, end_point, merge_option()).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.
175 176 177 |
# File 'lib/dyi/drawing/pen.rb', line 175 def draw_line_on_direction(canvas, start_point, direction_x, direction_y, ={}) Shape::Line.create_on_direction(start_point, direction_x, direction_y, merge_option()).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.
314 315 316 317 318 |
# File 'lib/dyi/drawing/pen.rb', line 314 def draw_path(canvas, point, ={}, &block) path = Shape::Path.new(point, merge_option()).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.
264 265 266 267 268 269 270 271 272 273 |
# File 'lib/dyi/drawing/pen.rb', line 264 def draw_polygon(canvas, points, ={}) if block_given? polygon = Shape::Polygon.new(points, merge_option()) yield polygon else polygon = Shape::Polygon.new(points.first, merge_option()) 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.
216 217 218 219 220 221 222 223 224 225 |
# File 'lib/dyi/drawing/pen.rb', line 216 def draw_polyline(canvas, points, ={}) if block_given? polyline = Shape::Polyline.new(points, merge_option()) yield polyline else polyline = Shape::Polyline.new(points.first, merge_option()) 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.
287 288 289 |
# File 'lib/dyi/drawing/pen.rb', line 287 def draw_rectangle(canvas, left_top_point, width, height, ={}) Shape::Rectangle.create_on_width_height(left_top_point, width, height, merge_option()).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.
301 302 303 |
# File 'lib/dyi/drawing/pen.rb', line 301 def draw_rectangle_on_corner(canvas, top, right, bottom, left, ={}) Shape::Rectangle.create_on_corner(top, right, bottom, left, merge_option()).draw_on(canvas) end |
#draw_sector(canvas, center_point, radius_x, radius_y, start_angle, center_angle, options = {}) ⇒ Shape::Path
Draws a circular sector.
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, ={}) start_angle = (center_angle > 0 ? start_angle : (start_angle + center_angle)) % 360 center_angle = center_angle.abs = merge_option() inner_radius = .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, ) else draw_toroid(canvas, center_point, radius_x, radius_y, inner_radius, ) 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, ) end end |
#draw_text(canvas, point, text, options = {}) ⇒ Shape::Text
Draws a text.
505 506 507 |
# File 'lib/dyi/drawing/pen.rb', line 505 def draw_text(canvas, point, text, ={}) Shape::Text.new(point, text, merge_option()).draw_on(canvas) end |
#draw_toroid(canvas, center_point, radius_x, radius_y, inner_radius, options = {}) ⇒ Shape::Path
Draws a toroid.
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, ={}) 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, ) {|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.
378 379 380 |
# File 'lib/dyi/drawing/pen.rb', line 378 def import_image(canvas, left_top_point, width, height, image_uri, ={}) Shape::ImageReference.new(left_top_point, width, height, image_uri, merge_option()).draw_on(canvas) end |