Class: Wx::SF::SolidArrow

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

Overview

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

Direct Known Subclasses

DiamondArrow, SquareArrow

Class Method Summary collapse

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

Constructor

Parameters:



21
22
23
24
# File 'lib/wx/shapes/arrows/solid_arrow.rb', line 21

def initialize(parent=nil)
  super
  scale
end

Class Method Details

.arrow(ratio) ⇒ Object



13
14
15
16
# File 'lib/wx/shapes/arrows/solid_arrow.rb', line 13

def arrow(ratio)
  x = ratio*11; y = ratio*5
  [Wx::RealPoint.new(0,0), Wx::RealPoint.new(x, y), Wx::RealPoint.new(x,-y), Wx::RealPoint.new(x,0)]
end

Instance Method Details

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

Returns translated connection point for arrow.

Returns:

  • (Wx::Point)

    translated connection point for arrow



42
43
44
45
46
47
48
49
50
51
# File 'lib/wx/shapes/arrows/solid_arrow.rb', line 42

def draw(from, to, dc)
  rarrow = translate_arrow(vertices, from, to)
  cp = rarrow.pop # get connection point
  dc.with_pen(pen) do |dc|
    dc.with_brush(fill) do |dc|
      dc.draw_polygon(rarrow)
    end
  end
  cp
end

#scaleObject (protected)



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

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

#verticesObject (protected)



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

def vertices
  @vertices ||= SolidArrow.arrow(@ratio)
end