lib/wx/shapes/arrows/diamond_arrow.rb in wxruby3-shapes-0.9.0.pre.beta.3 vs lib/wx/shapes/arrows/diamond_arrow.rb in wxruby3-shapes-0.9.5
- old
+ new
@@ -3,31 +3,26 @@
require 'wx/shapes/arrows/solid_arrow'
module Wx::SF
+ # Class extends the Wx::SolidArrow class and encapsulates
+ # solid diamond arrow shapes.
class DiamondArrow < SolidArrow
class << self
- def diamond_arrow
- @diamond_arrow ||= [Wx::RealPoint.new(0,0), Wx::RealPoint.new(10,4), Wx::RealPoint.new(20,0), Wx::RealPoint.new(10,-4)]
+ def arrow(ratio)
+ x = ratio*10; y = ratio*5
+ [Wx::RealPoint.new(0,0), Wx::RealPoint.new(x, y), Wx::RealPoint.new(2*x,0), Wx::RealPoint.new(x,-y), Wx::RealPoint.new(2*x,0)]
end
end
- # Draw arrow shape at the end of a virtual line.
- # @param [Wx::RealPoint] from Start of the virtual line
- # @param [Wx::RealPoint] to End of the virtual line
- # @param [Wx::DC] dc Device context for drawing
- def draw(from, to, dc)
- rarrow = translate_arrow(DiamondArrow.diamond_arrow, from, to)
- dc.with_pen(@pen) do |dc|
- dc.with_brush(@fill) do |dc|
- dc.draw_polygon(rarrow)
- end
- end
+ def vertices
+ @vertices ||= DiamondArrow.arrow(@ratio)
end
+ protected :vertices
end
end