mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-19 06:40:42 +00:00
Fix rotation in straight angle (fix #592)
This commit is contained in:
parent
a5536359bb
commit
56de0fe989
src
@ -396,7 +396,7 @@ void PixelsMovement::moveImage(const gfx::Point& pos, MoveModifier moveModifier)
|
||||
if ((moveModifier & AngleSnapMovement) == AngleSnapMovement) {
|
||||
// TODO make this configurable
|
||||
static const double keyAngles[] = {
|
||||
0.0, 26.565, 45.0, 63.435, 90.0, 116.565, 135.0, 153.435, -180.0,
|
||||
0.0, 26.565, 45.0, 63.435, 90.0, 116.565, 135.0, 153.435, 180.0,
|
||||
180.0, -153.435, -135.0, -116, -90.0, -63.435, -45.0, -26.565
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "gfx/transformation.h"
|
||||
#include "gfx/point.h"
|
||||
#include "gfx/size.h"
|
||||
#include "fixmath/fixmath.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@ -72,13 +73,18 @@ PointT<double> Transformation::rotatePoint(
|
||||
const PointT<double>& pivot,
|
||||
double angle)
|
||||
{
|
||||
double cos = std::cos(-angle);
|
||||
double sin = std::sin(-angle);
|
||||
double dx = (point.x-pivot.x);
|
||||
double dy = (point.y-pivot.y);
|
||||
using namespace fixmath;
|
||||
|
||||
fixed fixangle = ftofix(-angle);
|
||||
fixangle = fixmul(fixangle, radtofix_r);
|
||||
|
||||
fixed cos = fixcos(fixangle);
|
||||
fixed sin = fixsin(fixangle);
|
||||
fixed dx = fixsub(ftofix(point.x), ftofix(pivot.x));
|
||||
fixed dy = fixsub(ftofix(point.y), ftofix(pivot.y));
|
||||
return PointT<double>(
|
||||
pivot.x + dx*cos - dy*sin,
|
||||
pivot.y + dy*cos + dx*sin);
|
||||
fixtof(fixadd(ftofix(pivot.x), fixsub(fixmul(dx, cos), fixmul(dy, sin)))),
|
||||
fixtof(fixadd(ftofix(pivot.y), fixadd(fixmul(dy, cos), fixmul(dx, sin)))));
|
||||
}
|
||||
|
||||
Rect Transformation::transformedBounds() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user