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.3.1 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.3.0 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.24 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.23 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.22 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.21 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.20 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.19 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.18 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.17 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.16 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.15 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.14 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.13 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.12 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.11 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.10 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.9 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.8 lib/grid_generator/cubic/facing_square_factory.rb
grid_generator-0.2.7 lib/grid_generator/cubic/facing_square_factory.rb