Module: VectorSalad::Mixins::At
- Included in:
- StandardShapes::Circle, StandardShapes::IsoTri, StandardShapes::N, StandardShapes::Oval, StandardShapes::Polygon, StandardShapes::Rect
- Defined in:
- lib/vector_salad/mixins/at.rb
Overview
Mixin for positioning shapes.
Instance Method Summary (collapse)
-
- (Any) [](x, y)
Set the x, y coordinates of the shape.
-
- (Coords) at
Get the x, y coordinates of the shape.
-
- (Any) at=(at)
Set the x, y coordinates of the shape directly.
-
- (Any) move(x, y)
Move the shape relatively.
Instance Method Details
- (Any) [](x, y)
Set the x, y coordinates of the shape.
9 10 11 12 13 |
# File 'lib/vector_salad/mixins/at.rb', line 9 def [](x, y) shape = clone shape.at = [x, y] shape end |
- (Coords) at
Get the x, y coordinates of the shape.
17 18 19 |
# File 'lib/vector_salad/mixins/at.rb', line 17 def at [@x, @y] end |
- (Any) at=(at)
Set the x, y coordinates of the shape directly.
23 24 25 26 |
# File 'lib/vector_salad/mixins/at.rb', line 23 def at=(at) @x, @y = *at self end |
- (Any) move(x, y)
Move the shape relatively.
30 31 32 33 34 |
# File 'lib/vector_salad/mixins/at.rb', line 30 def move(x, y) shape = clone shape.at = [shape.at[0] + x, shape.at[1] + y] shape end |