mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-11 04:54:06 +01:00
14 lines
421 B
Plaintext
14 lines
421 B
Plaintext
function point_rotate(px, py, ox, oy, a) {
|
|
a = angle_difference(a, 0);
|
|
if(a == 0) return [ px, py ];
|
|
if(a == 180) return [ ox + (ox - px), oy + (oy - py) ];
|
|
if(a == 90) return [ ox + (oy - py), oy + (ox - px) ];
|
|
if(a == -90) return [ ox + (py - oy), oy + (px - ox) ];
|
|
|
|
var cx = px - ox;
|
|
var cy = py - oy;
|
|
var d = -degtorad(a);
|
|
|
|
return [ox + cx * cos(d) - cy * sin(d),
|
|
oy + cx * sin(d) + cy * cos(d)];
|
|
} |