Class: MagicCloud::Layouter
- Inherits:
-
Object
- Object
- MagicCloud::Layouter
- Defined in:
- lib/magic_cloud/layouter.rb,
lib/magic_cloud/layouter/place.rb
Overview
Main magic of magic cloud - layouting shapes without collisions. Also, alongside with CollisionBoard - the slowest and algorithmically trickiest part.
Defined Under Namespace
Classes: Place, PlaceNotFound
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(w, h, options = {}) ⇒ Layouter
constructor
A new instance of Layouter.
- #layout!(shapes) ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(w, h, options = {}) ⇒ Layouter
Returns a new instance of Layouter.
10 11 12 13 14 |
# File 'lib/magic_cloud/layouter.rb', line 10 def initialize(w, h, = {}) @board = CollisionBoard.new(w, h) @options = end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
16 17 18 |
# File 'lib/magic_cloud/layouter.rb', line 16 def board @board end |
Instance Method Details
#height ⇒ Object
22 23 24 |
# File 'lib/magic_cloud/layouter.rb', line 22 def height board.height end |
#layout!(shapes) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/magic_cloud/layouter.rb', line 26 def layout!(shapes) visible_shapes = [] shapes.each do |shape| next unless find_place(shape) visible_shapes.push(shape) end visible_shapes end |
#width ⇒ Object
18 19 20 |
# File 'lib/magic_cloud/layouter.rb', line 18 def width board.width end |