Class: GridGenerator::Cubic::IsoView
- Inherits:
-
Object
- Object
- GridGenerator::Cubic::IsoView
- Defined in:
- lib/grid_generator/cubic/iso_view.rb
Instance Attribute Summary collapse
-
#front ⇒ Object
readonly
Returns the value of attribute front.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#top ⇒ Object
readonly
Returns the value of attribute top.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(x:, y:, units:, top_squares:, front_squares:, right_squares:) ⇒ IsoView
constructor
A new instance of IsoView.
- #to_svg ⇒ Object
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
#front ⇒ Object (readonly)
Returns the value of attribute front.
23 24 25 |
# File 'lib/grid_generator/cubic/iso_view.rb', line 23 def front @front end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
23 24 25 |
# File 'lib/grid_generator/cubic/iso_view.rb', line 23 def right @right end |
#top ⇒ Object (readonly)
Returns the value of attribute top.
23 24 25 |
# File 'lib/grid_generator/cubic/iso_view.rb', line 23 def top @top end |
#units ⇒ Object (readonly)
Returns the value of attribute units.
23 24 25 |
# File 'lib/grid_generator/cubic/iso_view.rb', line 23 def units @units end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
23 24 25 |
# File 'lib/grid_generator/cubic/iso_view.rb', line 23 def x @x end |
#y ⇒ Object (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_json ⇒ Object
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_svg ⇒ Object
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 |