Module: Dieses::Application::Pen::Draw::Movements
- Included in:
- Dieses::Application::Pen::Draw
- Defined in:
- lib/dieses/application/pen.rb
Instance Method Summary collapse
- #cross(distance = 1, angle: Undefined) ⇒ Object
- #down(y = 1) ⇒ Object
- #left(x = 1) ⇒ Object
- #move(x: Undefined, y: Undefined) ⇒ Object
- #right(x = 1) ⇒ Object
- #up(y = 1) ⇒ Object
Instance Method Details
#cross(distance = 1, angle: Undefined) ⇒ Object
129 130 131 132 |
# File 'lib/dieses/application/pen.rb', line 129 def cross(distance = 1, angle: Undefined) radian = Undefined.equal?(angle) ? perfect.angle : Support.to_radian(angle) move x: distance * Math.cos(radian), y: distance * Math.sin(radian) end |
#down(y = 1) ⇒ Object
117 118 119 |
# File 'lib/dieses/application/pen.rb', line 117 def down(y = 1) move y: y end |
#left(x = 1) ⇒ Object
121 122 123 |
# File 'lib/dieses/application/pen.rb', line 121 def left(x = 1) move x: -x end |
#move(x: Undefined, y: Undefined) ⇒ Object
106 107 108 109 110 111 |
# File 'lib/dieses/application/pen.rb', line 106 def move(x: Undefined, y: Undefined) tap do pos.translate!(x: x * ruler.unit) unless Undefined.equal?(x) pos.translate!(y: y * ruler.unit) unless Undefined.equal?(y) end end |
#right(x = 1) ⇒ Object
125 126 127 |
# File 'lib/dieses/application/pen.rb', line 125 def right(x = 1) move x: x end |
#up(y = 1) ⇒ Object
113 114 115 |
# File 'lib/dieses/application/pen.rb', line 113 def up(y = 1) move y: -y end |