Sha256: 75e79af1feaf1d5de8ba560887ec29a99966a5e1d7c3d5081e70b881f814c783
Contents?: true
Size: 668 Bytes
Versions: 2
Compression:
Stored size: 668 Bytes
Contents
module Straightedge::Figures class Hexagon < Figure attr_accessor :scale def initialize(location: Straightedge::ORIGIN, color: :white, scale: 1.0) super(location: location, color: color) @scale = scale @marks = corners end # lots of magic here... def left_triangle corners[0..2] end def right_triangle corners[3..5] end def center_quad [corners[0], corners[2], corners[3], corners[5]] end def corners Array.new(6) do |i| angle = 2 * Math::PI / 6 * (i+2) x_i = x + scale * Math.cos(angle) y_i = y + scale * Math.sin(angle) [x_i, y_i] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
straightedge-0.1.2 | lib/straightedge/figures/hexagon.rb |
straightedge-0.1.1 | lib/straightedge/figures/hexagon.rb |