class DYI::Drawing::CylinderBrush
@since 0.0.0
Public Class Methods
new(options={})
click to toggle source
@since 1.1.0
Calls superclass method
DYI::Drawing::Brush::new
# File lib/dyi/drawing/pen_3d.rb, line 117 def initialize(options={}) self.ry = options.delete(:ry) super end
Public Instance Methods
draw_rectangle(canvas, left_top_point, width, height, options={})
click to toggle source
# File lib/dyi/drawing/pen_3d.rb, line 144 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()
click to toggle source
# File lib/dyi/drawing/pen_3d.rb, line 130 def fill @painting.fill end
Also aliased as: color
fill=(value)
click to toggle source
# File lib/dyi/drawing/pen_3d.rb, line 134 def fill=(value) if @painting.fill != Color.new_or_nil(value) @painting.fill = Color.new_or_nil(value) end value end
Also aliased as: color=
ry()
click to toggle source
# File lib/dyi/drawing/pen_3d.rb, line 122 def ry @ry || Length.new(8) end
ry=(value)
click to toggle source
# File lib/dyi/drawing/pen_3d.rb, line 126 def ry=(value) @ry = Length.new_or_nil(value) end
Private Instance Methods
body_gradient(canvas)
click to toggle source
# File lib/dyi/drawing/pen_3d.rb, line 165 def body_gradient(canvas) gradient = ColorEffect::LinearGradient.new([0,0],[1,0]) gradient.add_color(0, color.merge(Color.white, 0.4)) gradient.add_color(0.3, color.merge(Color.white, 0.65)) gradient.add_color(0.4, color.merge(Color.white, 0.7)) gradient.add_color(0.5, color.merge(Color.white, 0.65)) gradient.add_color(0.7, color.merge(Color.white, 0.4)) gradient.add_color(1, color) gradient end
top_color()
click to toggle source
# File lib/dyi/drawing/pen_3d.rb, line 176 def top_color color.merge(Color.white, 0.3) end