Class: GridGenerator::Cubic::IsoView

Inherits:
Object
  • Object
show all
Defined in:
lib/grid_generator/cubic/iso_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:, units:, top_squares:, front_squares:, right_squares:) ⇒ IsoView

Returns a new instance of IsoView.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/grid_generator/cubic/iso_view.rb', line 8

def initialize(x: , y: , units: , top_squares: , front_squares: , right_squares:)
  @x, @y = x, y
  @units = units
  top_x = x
  top_y = y
  @top = GridGenerator::Cubic::TopGrid.new(x: top_x, y: top_y, units: units, squares: top_squares) 
  front_x = x
  front_y = y + top.squares.size * units / 2 # y + (top.squares.size * units / 2)
  @front = GridGenerator::Cubic::FrontGrid.new(x: front_x, y: front_y, units: units, squares: front_squares) 

  right_x = x + top.squares.first.size * units 
  right_y = y + top.squares.first.size * units / 2
  @right = GridGenerator::Cubic::RightGrid.new(x: right_x, y: right_y, units: units, squares: right_squares) 
end

Instance Attribute Details

#frontObject (readonly)

Returns the value of attribute front.



23
24
25
# File 'lib/grid_generator/cubic/iso_view.rb', line 23

def front
  @front
end

#rightObject (readonly)

Returns the value of attribute right.



23
24
25
# File 'lib/grid_generator/cubic/iso_view.rb', line 23

def right
  @right
end

#topObject (readonly)

Returns the value of attribute top.



23
24
25
# File 'lib/grid_generator/cubic/iso_view.rb', line 23

def top
  @top
end

#unitsObject (readonly)

Returns the value of attribute units.



23
24
25
# File 'lib/grid_generator/cubic/iso_view.rb', line 23

def units
  @units
end

#xObject (readonly)

Returns the value of attribute x.



23
24
25
# File 'lib/grid_generator/cubic/iso_view.rb', line 23

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



23
24
25
# File 'lib/grid_generator/cubic/iso_view.rb', line 23

def y
  @y
end

Instance Method Details

#as_jsonObject



25
26
27
28
29
30
31
# File 'lib/grid_generator/cubic/iso_view.rb', line 25

def as_json
  {
    "top" => top.as_json,
    "front" => front.as_json,
    "right" => right.as_json
  }
end

#to_svgObject



33
34
35
36
37
38
# File 'lib/grid_generator/cubic/iso_view.rb', line 33

def to_svg
  output = top.to_svg
  output += front.to_svg
  output += right.to_svg
  output
end