Class: VectorSalad::StandardShapes::IsoTri

Inherits:
BasicShape
  • Object
show all
Includes:
Mixins::At
Defined in:
lib/vector_salad/standard_shapes/iso_tri.rb

Overview

Isosceles or right-angle triangle shape.

Instance Attribute Summary collapse

Attributes inherited from BasicShape

#options

Instance Method Summary collapse

Methods included from Mixins::At

#[], #at, #at=, #move

Methods inherited from BasicShape

#flip, #flip_x, #flip_y, #jitter, #move, #rotate, #scale, #to_a, #to_bezier_path, #to_cubic_path, #to_multi_path, #to_simple_path, #to_svg

Constructor Details

#initialize(width = nil, height, **options) ⇒ IsoTri

Returns a new instance of IsoTri.



21
22
23
24
25
26
27
# File 'lib/vector_salad/standard_shapes/iso_tri.rb', line 21

def initialize(width = nil, height, **options)
  width = height * 2 if width.nil?
  @width, @height = width, height
  @options = options
  @x, @y = 0, 0
  self
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



11
12
13
# File 'lib/vector_salad/standard_shapes/iso_tri.rb', line 11

def height
  @height
end

Instance Method Details

#to_pathObject

Convert the shape to a path



30
31
32
33
34
35
36
37
# File 'lib/vector_salad/standard_shapes/iso_tri.rb', line 30

def to_path
  Path.new(
    N.n(@x, @y),
    N.n(@x - @width / 2, @y + @height),
    N.n(@x + @width / 2, @y + @height),
    **@options
  )
end