Module: VectorSalad::Mixins::At

Overview

Mixin for positioning shapes.

Instance Method Summary collapse

Instance Method Details

#[](x, y) ⇒ Object



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

#atObject



17
18
19
# File 'lib/vector_salad/mixins/at.rb', line 17

def at
  [@x, @y]
end

#at=(at) ⇒ Object



23
24
25
26
# File 'lib/vector_salad/mixins/at.rb', line 23

def at=(at)
  @x, @y = *at
  self
end

#move(x, y) ⇒ Object



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