summaryrefslogtreecommitdiffstats
path: root/generic/tkRectOval.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2019-03-13 19:16:12 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2019-03-13 19:16:12 (GMT)
commit913c2ffec66a261d7cea357c21cdcda60132c0a5 (patch)
tree50834dfff8ea8a4494f981b6559bbfa604ee7707 /generic/tkRectOval.c
parent87a95ec0329c9fd676ed4a5d9d10247eb245a4ec (diff)
downloadtk-913c2ffec66a261d7cea357c21cdcda60132c0a5.zip
tk-913c2ffec66a261d7cea357c21cdcda60132c0a5.tar.gz
tk-913c2ffec66a261d7cea357c21cdcda60132c0a5.tar.bz2
Document. Factor out basic rotation function.
Diffstat (limited to 'generic/tkRectOval.c')
-rw-r--r--generic/tkRectOval.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c
index b1bce7b..279e89e 100644
--- a/generic/tkRectOval.c
+++ b/generic/tkRectOval.c
@@ -1306,19 +1306,6 @@ OvalToArea(
*--------------------------------------------------------------
*/
-static inline void
-DoRotate(
- double originX, double originY,
- double sine, double cosine,
- double *xPtr, double *yPtr)
-{
- double x = *xPtr - originX;
- double y = *yPtr - originY;
-
- *xPtr = originX + x * cosine - y * sine;
- *yPtr = originY + x * sine + y * cosine;
-}
-
static void
RotateRectOval(
Tk_Canvas canvas, /* Canvas containing rectangle. */
@@ -1329,10 +1316,20 @@ RotateRectOval(
{
RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
double s = sin(angleRad), c = cos(angleRad);
- double *coords = rectOvalPtr->bbox;
+ double coords[4];
+
+ memcpy(coords, rectOvalPtr->bbox, sizeof(coords));
+ TkRotatePoint(originX, originY, s, c, &coords[0], &coords[1]);
+ TkRotatePoint(originX, originY, s, c, &coords[2], &coords[3]);
+
+ /*
+ * Sort the points for the bounding box.
+ */
- DoRotate(originX, originY, s, c, &coords[0], &coords[1]);
- DoRotate(originX, originY, s, c, &coords[2], &coords[3]);
+ rectOvalPtr->bbox[0] = (coords[0] < coords[2]) ? coords[0] : coords[2];
+ rectOvalPtr->bbox[1] = (coords[1] < coords[3]) ? coords[1] : coords[3];
+ rectOvalPtr->bbox[2] = (coords[0] < coords[2]) ? coords[2] : coords[0];
+ rectOvalPtr->bbox[3] = (coords[1] < coords[3]) ? coords[3] : coords[1];
ComputeRectOvalBbox(canvas, rectOvalPtr);
}