Class: DYI::Drawing::CubicPen

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

Overview

Since:

  • 0.0.0

Constant Summary collapse

POSITION_TYPE_VALUES =

Since:

  • 0.0.0

[:baseline, :center, :backline]

Constants inherited from Pen

Pen::ALIAS_ATTRIBUTES

Constants inherited from PenBase

PenBase::DROP_SHADOW_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from Pen

#color, #dasharray, #dashoffset, #linecap, #linejoin, #miterlimit, #width

Attributes inherited from PenBase

#display, #drop_shadow, #fill, #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 Pen

#draw_text, method_missing

Methods inherited from PenBase

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

Constructor Details

#initialize(options = {}) ⇒ CubicPen

Returns a new instance of CubicPen.

Since:

  • 0.0.0



31
32
33
34
35
36
37
38
# File 'lib/dyi/drawing/pen_3d.rb', line 31

def initialize(options={})
  self.position_type = options.delete(:position_type)
  self.background_color = options.delete(:background_color)
  self.background_opacity = options.delete(:background_opacity)
  self.dx = options.delete(:dx)
  self.dy = options.delete(:dy)
  super
end

Instance Attribute Details

#background_colorObject

Since:

  • 0.0.0



29
30
31
# File 'lib/dyi/drawing/pen_3d.rb', line 29

def background_color
  @background_color
end

#background_opacityObject

Since:

  • 0.0.0



29
30
31
# File 'lib/dyi/drawing/pen_3d.rb', line 29

def background_opacity
  @background_opacity
end

#dxObject

Since:

  • 0.0.0



29
30
31
# File 'lib/dyi/drawing/pen_3d.rb', line 29

def dx
  @dx
end

#dyObject

Since:

  • 0.0.0



29
30
31
# File 'lib/dyi/drawing/pen_3d.rb', line 29

def dy
  @dy
end

#position_typeObject

Since:

  • 0.0.0



29
30
31
# File 'lib/dyi/drawing/pen_3d.rb', line 29

def position_type
  @position_type
end

Instance Method Details

#brushObject

Since:

  • 0.0.0



73
74
75
# File 'lib/dyi/drawing/pen_3d.rb', line 73

def brush
  @brush ||= Brush.new(:color => background_color || color, :opacity => background_opacity || nil)
end

#draw_line(canvas, start_point, end_point, options = {}) ⇒ Object

Since:

  • 0.0.0



77
78
79
80
81
82
83
# File 'lib/dyi/drawing/pen_3d.rb', line 77

def draw_line(canvas, start_point, end_point, options={})
  group = Shape::ShapeGroup.new
  draw_background_shape(group, start_point, end_point, options)
  super(group, start_point, end_point, options)
  adjust_z_coordinate(group)
  group.draw_on(canvas)
end

#draw_polyline(canvas, point, options = {}, &block) ⇒ Object

Since:

  • 0.0.0



85
86
87
88
89
90
91
92
93
94
# File 'lib/dyi/drawing/pen_3d.rb', line 85

def draw_polyline(canvas, point, options={}, &block)
  group = Shape::ShapeGroup.new(options)
  polyline = super(group, point, {}, &block)
  (1...polyline.points.size).each do |i|
    draw_background_shape(group, polyline.points[i-1], polyline.points[i], {})
  end
  polyline = super(group, point, {}, &block)
  adjust_z_coordinate(group)
  group.draw_on(canvas)
end