Sha256: 5ccfc29b4eabe7f9960057a68b073d0fda788aea1579a2e3f8dee64b5e95784b

Contents?: true

Size: 808 Bytes

Versions: 57

Compression:

Stored size: 808 Bytes

Contents

require_relative '../base_element'

module GridGenerator
  module Cubic
    class FacingSquareFactory
      def initialize(x: , y:, width:, height:, colour:, opacity:)
        @x, @y = x, y
        @width, @height = width, height
        @colour, @opacity = colour, opacity
      end

      attr_reader :x, :y, :width, :height, :colour, :opacity

      def max_x
        x + width 
      end
  
      def max_y
        y + height 
      end

      def points
        [
          Matrix.column_vector([ x, y ]),
          Matrix.column_vector([ max_x, y ]),
          Matrix.column_vector([ max_x, max_y ]),
          Matrix.column_vector([ x, max_y ])
        ]
      end

      def build
        GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity)
      end
    end
  end
end


Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
grid_generator-0.6.7 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.6.6 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.6.5 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.6.4 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.6.3 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.6.2 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.6.1 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.6.0 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.5.3 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.5.2 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.5.1 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.5.0 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.4.5 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.4.4 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.4.3 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.4.2 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.4.1 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.4.0 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.3.3 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.3.2 lib/grid_generator/cubic/facing_square_factory.rb