Class: Wx::SF::CupArrow

Inherits:
LineArrow show all
Defined in:
lib/wx/shapes/arrows/cup_arrow.rb

Overview

Class extends the Wx::SolidArrow class and encapsulates cup arrow shapes.

Constant Summary collapse

RADIUS =

Default arc radius size

7

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LineArrow

#get_pen, #get_pen_width, #set_parent_shape, #set_pen

Methods inherited from ArrowBase

#get_parent_shape, #set_parent_shape, #translate_arrow

Constructor Details

#initialize(parent = nil) ⇒ CupArrow

Constructor

Parameters:



25
26
27
28
# File 'lib/wx/shapes/arrows/cup_arrow.rb', line 25

def initialize(parent=nil)
  super
  scale
end

Class Method Details

.arrow(radius) ⇒ Object



17
18
19
# File 'lib/wx/shapes/arrows/cup_arrow.rb', line 17

def arrow(radius)
  [Wx::RealPoint.new(0, radius), Wx::RealPoint.new(0, -radius), Wx::RealPoint.new(0, 0), Wx::RealPoint.new(radius, 0)]
end

Instance Method Details

#coordsObject (protected)



36
37
38
# File 'lib/wx/shapes/arrows/cup_arrow.rb', line 36

def coords
  @coords ||= CupArrow.arrow(get_radius)
end

#draw(from, to, dc) ⇒ Wx::Point

Draw arrow shape at the end of a virtual line.

Parameters:

  • from (Wx::RealPoint)

    Start of the virtual line

  • to (Wx::RealPoint)

    End of the virtual line

  • dc (Wx::DC)

    Device context for drawing

Returns:

  • (Wx::Point)

    translated connection point for arrow



52
53
54
55
56
57
58
59
60
61
# File 'lib/wx/shapes/arrows/cup_arrow.rb', line 52

def draw(from, to, dc)
  rarrow = translate_arrow(coords, from, to)
  cp = rarrow.pop
  dc.with_pen(pen) do |dc|
    dc.with_brush(Wx::TRANSPARENT_BRUSH) do |dc|
      dc.draw_arc(*rarrow)
    end
  end
  cp
end

#get_radiusObject Also known as: radius

Get the circle radius



31
32
33
# File 'lib/wx/shapes/arrows/cup_arrow.rb', line 31

def get_radius
  (RADIUS * @ratio).to_i
end

#scaleObject (protected)



41
42
43
44
# File 'lib/wx/shapes/arrows/cup_arrow.rb', line 41

def scale
  @coords = nil
  @ratio = 1 + (pen_width / 2) * 0.5
end