Sha256: 762da7bb9348e13553e44d61393e968e930956bac8e8f3aebd92e59dc1639471
Contents?: true
Size: 1.01 KB
Versions: 7
Compression:
Stored size: 1.01 KB
Contents
require_relative '../base_element' module GridGenerator module Pyraminx class TriangleFactory def initialize(x:, y:, units:, direction:, colour:, opacity:) @x, @y = x, y @units = units @direction = direction @colour = colour @opacity = opacity end attr_reader :x, :y, :units, :direction, :colour, :opacity def up_points [ Matrix.column_vector([ x+units, y ]), Matrix.column_vector([ x+2*units, y+units ]), Matrix.column_vector([ x, y+units ]) ] end def down_points [ Matrix.column_vector([ x+units, y+units ]), Matrix.column_vector([ x+2*units, y ]), Matrix.column_vector([ x, y ]) ] end def points if direction == :up up_points else down_points end end def build GridGenerator::BaseElement.new(points: points, colour: colour, opacity: opacity) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems