Class: CooCoo::Image::Rotate
- Defined in:
- lib/coo-coo/image.rb
Instance Method Summary collapse
- #call(x, y) ⇒ Object
-
#initialize(ox, oy, radians) ⇒ Rotate
constructor
A new instance of Rotate.
Methods inherited from Transform
Constructor Details
#initialize(ox, oy, radians) ⇒ Rotate
Returns a new instance of Rotate.
201 202 203 204 205 206 |
# File 'lib/coo-coo/image.rb', line 201 def initialize(ox, oy, radians) super() @ox = ox @oy = oy @radians = radians end |
Instance Method Details
#call(x, y) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/coo-coo/image.rb', line 208 def call(x, y) c = ::Math.cos(@radians) s = ::Math.sin(@radians) x = x - @ox y = y - @oy nx = x * c - y * s ny = x * s + y * c nx = nx + @ox ny = ny + @oy [ nx.floor, ny.floor ] end |