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.4 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.3 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.2 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.1 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.2.0 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.12 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.11 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.10 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.9 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.8 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.7 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.6 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.5 lib/grid_generator/arrows/horizontal_arrow.rb
grid_generator-0.1.4 lib/grid_generator/arrows/horizontal_arrow.rb