summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvPoly.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-05-10 08:04:39 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-05-10 08:04:39 (GMT)
commitebee84d3759fbe688f9a527facf83e5dc30ae5a0 (patch)
tree9b196dabbce4109b631ce7307b57a7e821113912 /generic/tkCanvPoly.c
parent2cf64c85fc09764112c6d2daa54f22c9b2c3b549 (diff)
parent50b390e8c37fc97708f980d5cdd9fb5480b64e4c (diff)
downloadtk-ebee84d3759fbe688f9a527facf83e5dc30ae5a0.zip
tk-ebee84d3759fbe688f9a527facf83e5dc30ae5a0.tar.gz
tk-ebee84d3759fbe688f9a527facf83e5dc30ae5a0.tar.bz2
Merge trunk
Diffstat (limited to 'generic/tkCanvPoly.c')
-rw-r--r--generic/tkCanvPoly.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index f10aae7..0b2d134 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -176,6 +176,8 @@ static double PolygonToPoint(Tk_Canvas canvas,
Tk_Item *itemPtr, double *pointPtr);
static int PolygonToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
+static void RotatePolygon(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScalePolygon(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -202,13 +204,14 @@ Tk_ItemType tkPolygonType = {
PolygonToPostscript, /* postscriptProc */
ScalePolygon, /* scaleProc */
TranslatePolygon, /* translateProc */
- GetPolygonIndex, /* indexProc */
+ GetPolygonIndex, /* indexProc */
NULL, /* icursorProc */
NULL, /* selectionProc */
- PolygonInsert, /* insertProc */
+ PolygonInsert, /* insertProc */
PolygonDeleteCoords, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotatePolygon, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -1738,6 +1741,44 @@ GetPolygonIndex(
/*
*--------------------------------------------------------------
*
+ * RotatePolygon --
+ *
+ * This function is called to rotate a polygon by a given amount about a
+ * point.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the polygon is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotatePolygon(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being moved. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ PolygonItem *polyPtr = (PolygonItem *) itemPtr;
+ double *coordPtr;
+ int i;
+ double s = sin(angleRad), c = cos(angleRad);
+
+ for (i = 0, coordPtr = polyPtr->coordPtr; i < polyPtr->numPoints;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ ComputePolygonBbox(canvas, polyPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* TranslatePolygon --
*
* This function is called to move a polygon by a given amount.