Class: DYI::Drawing::CylinderBrush
Overview
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.
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
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
|
#fill ⇒ Object
Also known as:
color
131
132
133
|
# File 'lib/dyi/drawing/pen_3d.rb', line 131
def fill
@painting.fill
end
|
#fill=(value) ⇒ Object
Also known as:
color=
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
|
#ry ⇒ Object
123
124
125
|
# File 'lib/dyi/drawing/pen_3d.rb', line 123
def ry
@ry || Length.new(8)
end
|
#ry=(value) ⇒ Object
127
128
129
|
# File 'lib/dyi/drawing/pen_3d.rb', line 127
def ry=(value)
@ry = Length.new_or_nil(value)
end
|