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)

Instance Method Summary (collapse)

Constructor Details

- (IsoTri) initialize(width = nil, height, **options)

Returns a new instance of IsoTri



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

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

- (Object) height (readonly)

Returns the value of attribute height



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

def height
  @height
end

- (Object) options Originally defined in class BasicShape

Returns the value of attribute options

Instance Method Details

- (Any) [](x, y) Originally defined in module Mixins::At

Set the x, y coordinates of the shape.

Parameters:

  • x (Coord)

    +Num; a coordinate+

  • y (Coord)

    +Num; a coordinate+

Returns:

  • (Any)

- (Coords) at Originally defined in module Mixins::At

Get the x, y coordinates of the shape.

Returns:

  • (Coords)

    +[Num, Num] an x,y coordinate array+

- (Any) at=(at) Originally defined in module Mixins::At

Set the x, y coordinates of the shape directly.

Parameters:

  • at (Coords)

    +[Num, Num] an x,y coordinate array+

Returns:

  • (Any)

- (Any) move(x, y) Originally defined in module Mixins::At

Move the shape relatively.

Parameters:

  • x (Coord)

    +Num; a coordinate+

  • y (Coord)

    +Num; a coordinate+

Returns:

  • (Any)

- (Object) to_path

Convert the shape to a path



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

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