Rectangle snapping.
This commit is contained in:
parent
929d99f80c
commit
e06d8e4d15
@ -1553,5 +1553,10 @@ ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2)
|
||||
|
||||
ui::Point GameView::rectSnapCoords(ui::Point point1, ui::Point point2)
|
||||
{
|
||||
return point2;
|
||||
}
|
||||
ui::Point newPoint(0, 0);
|
||||
float snapAngle = floor((atan2(point2.Y-point1.Y, point2.X-point1.X)+M_PI*0.25)/(M_PI*0.5)+0.5)*M_PI*0.5 - M_PI*0.25;
|
||||
float lineMag = sqrtf(pow((float)(point2.X-point1.X),2)+pow((float)(point2.Y-point1.Y),2));
|
||||
newPoint.X = (int)(lineMag*cos(snapAngle)+point1.X+0.5f);
|
||||
newPoint.Y = (int)(lineMag*sin(snapAngle)+point1.Y+0.5f);
|
||||
return newPoint;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user