Sha256: a389e770833dc60e50aae25d3300462d12a0f59ec51a41e84a61fa8375312dbc

Contents?: true

Size: 1.66 KB

Versions: 34

Compression:

Stored size: 1.66 KB

Contents

require_relative 'arrow'

module GridGenerator
  module Arrows
    class HorizontalArrow < Arrow
      ARROW_WIDTH = 16
      ARROW_LENGTH = 8
      LINE_WIDTH = 6
    
      def arrow_start_point
        [
          [ x+ARROW_LENGTH, y+ARROW_WIDTH ],
          [ x, y+(ARROW_WIDTH/2) ],
          [ x+ARROW_LENGTH, y ]
        ]
      end
    
      def arrow_start_flat
        [
          [ x, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ],
          [ x, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ]
        ]
      end
    
      def arrow_start_side
        [
          [ x+ARROW_LENGTH, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ],
          [ x+ARROW_LENGTH+length, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ]
        ]
      end
    
      def arrow_end_point
        [
          [ x+ARROW_LENGTH+length, y ],
          [ x+(2*ARROW_LENGTH)+length, y+(ARROW_WIDTH/2) ],
          [ x+ARROW_LENGTH+length, y+ARROW_WIDTH ]
        ]
      end
    
      def arrow_end_flat
        [
          [ x+(2*ARROW_LENGTH)+length, y+(ARROW_WIDTH/2)-(LINE_WIDTH/2) ],
          [ x+(2*ARROW_LENGTH)+length, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ]
        ]
      end
    
      def arrow_end_side
        [
          [ x+ARROW_LENGTH+length, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ],
          [ x+ARROW_LENGTH, y+(ARROW_WIDTH/2)+(LINE_WIDTH/2) ]
        ]
      end 
    
      def points
        case direction
        when :forward
          arrow_start_flat + arrow_start_side + arrow_end_point + arrow_end_side
        when :backward
          arrow_start_point + arrow_start_side + arrow_end_flat + arrow_end_side
        else
          arrow_start_point + arrow_start_side + arrow_end_point + arrow_end_side
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
grid_generator-0.2.24 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.23 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.22 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.21 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.20 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.19 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.18 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.17 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.16 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.15 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.14 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.13 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.12 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.11 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.10 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.9 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.8 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.7 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.6 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.5 lib/grid_generator/arrows/horizontal_arrow.rb