Class: DYI::Drawing::CylinderBrush

Inherits:
Brush show all
Defined in:
lib/dyi/drawing/pen_3d.rb

Overview

Since:

  • 0.0.0

Constant Summary

Constants inherited from Brush

Brush::ALIAS_ATTRIBUTES

Constants inherited from PenBase

PenBase::DROP_SHADOW_OPTIONS

Instance Attribute Summary

Attributes inherited from Brush

#rule

Attributes inherited from PenBase

#display, #drop_shadow, #fill_opacity, #fill_rule, #opacity, #stroke, #stroke_dasharray, #stroke_dashoffset, #stroke_linecap, #stroke_linejoin, #stroke_miterlimit, #stroke_opacity, #stroke_width, #visibility

Instance Method Summary collapse

Methods inherited from Brush

method_missing

Methods inherited from PenBase

#draw_circle, #draw_closed_path, #draw_ellipse, #draw_image, #draw_line, #draw_line_on_direction, #draw_path, #draw_polygon, #draw_polyline, #draw_rectangle_on_corner, #draw_sector, #draw_text, #draw_toroid, #import_image

Constructor Details

#initialize(options = {}) ⇒ CylinderBrush

Returns a new instance of CylinderBrush.

Since:

  • 1.1.0



118
119
120
121
# File 'lib/dyi/drawing/pen_3d.rb', line 118

def initialize(options={})
  self.ry = options.delete(:ry)
  super
end

Instance Method Details

#draw_rectangle(canvas, left_top_point, width, height, options = {}) ⇒ Object

Since:

  • 0.0.0



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/dyi/drawing/pen_3d.rb', line 145

def draw_rectangle(canvas, left_top_point, width, height, options={})
  radius_x = width.quo(2)
  radius_y = ry

  shape = Shape::ShapeGroup.draw_on(canvas)
  top_painting = @painting.clone
  top_painting.fill = top_color
  Shape::Ellipse.create_on_center_radius(Coordinate.new(left_top_point) + [width.quo(2), 0], radius_x, radius_y, merge_option(:painting => top_painting)).draw_on(shape)
  body_painting = @painting.clone
  body_painting.fill = body_gradient(canvas)
  Shape::Path.draw(left_top_point, merge_option(:painting => body_painting)) {|path|
    path.rarc_to([width, 0], radius_x, radius_y, 0, false, false)
    path.rline_to([0, height])
    path.rarc_to([-width, 0], radius_x, radius_y, 0, false, true)
    path.rline_to([0, -height])
  }.draw_on(shape)
  shape
end

#fillObject Also known as: color

Since:

  • 0.0.0



131
132
133
# File 'lib/dyi/drawing/pen_3d.rb', line 131

def fill
  @painting.fill
end

#fill=(value) ⇒ Object Also known as: color=

Since:

  • 0.0.0



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

def fill=(value)
  if @painting.fill != Color.new_or_nil(value)
    @painting.fill = Color.new_or_nil(value)
  end
  value
end

#ryObject

Since:

  • 0.0.0



123
124
125
# File 'lib/dyi/drawing/pen_3d.rb', line 123

def ry
  @ry || Length.new(8)
end

#ry=(value) ⇒ Object

Since:

  • 0.0.0



127
128
129
# File 'lib/dyi/drawing/pen_3d.rb', line 127

def ry=(value)
  @ry = Length.new_or_nil(value)
end