Class: Wx::SF::CircleArrow

Inherits:
FilledArrow show all
Defined in:
lib/wx/shapes/arrows/circle_arrow.rb

Overview

Class extends the Wx::FilledArrow class and encapsulates circle arrow shapes.

Constant Summary collapse

RADIUS =

Default circle radius.

6

Instance Method Summary collapse

Methods inherited from FilledArrow

#get_fill, #set_fill

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) ⇒ CircleArrow

Constructor

Parameters:



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

def initialize(parent=nil)
  super
  scale
end

Instance Method Details

#draw(from, to, dc) ⇒ Object

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



37
38
39
40
41
42
43
44
45
46
# File 'lib/wx/shapes/arrows/circle_arrow.rb', line 37

def draw(from, to, dc)
  r = radius
  centre, cp = translate_arrow([Wx::RealPoint.new(r, 0), Wx::RealPoint.new(2*r, 0)], from, to)
  dc.with_pen(pen) do |dc|
    dc.with_brush(fill) do |dc|
      dc.draw_circle(centre, r)
    end
  end
  cp
end

#get_radiusObject Also known as: radius

Get the circle radius



23
24
25
# File 'lib/wx/shapes/arrows/circle_arrow.rb', line 23

def get_radius
  (RADIUS * @ratio).to_i
end

#scaleObject (protected)



28
29
30
# File 'lib/wx/shapes/arrows/circle_arrow.rb', line 28

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