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