Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip-164 Excluding Merge-Ins
This is equivalent to a diff from 6eaf88ea to 320b73bd
2019-04-14
| ||
15:27 | Implement TIP 164 check-in: 180d43e4 user: dkf tags: trunk | |
2019-03-16
| ||
14:54 | Tests of rotation Closed-Leaf check-in: 320b73bd user: dkf tags: tip-164 | |
2019-03-15
| ||
18:41 | Make some items have a virtual centre point to move. Much saner behaviour. check-in: 96c17d59 user: dkf tags: tip-164 | |
2019-03-14
| ||
21:01 | Fix [609e0045f5]: MouseWheel binding for canvas on MacOS provides wrong values for %x %y check-in: 45d655d3 user: fvogel tags: trunk | |
2019-03-11
| ||
09:43 | Basic implementation of TIP 164: [$canvas rotate] check-in: a79c0900 user: dkf tags: tip-164 | |
2019-03-07
| ||
17:16 | Fixed one more None -> NULL compiler warning. check-in: 6eaf88ea user: culler tags: trunk | |
2019-03-06
| ||
11:16 | Copy PDBs to installation if option PDBS is given during install check-in: f43280ce user: apnadkarni tags: trunk | |
Changes to doc/CrtItemType.3.
︙ | |||
79 80 81 82 83 84 85 86 87 88 89 90 91 92 | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | + + + | Tk_ItemTranslateProc *\fItranslateProc\fR; Tk_ItemIndexProc *\fIindexProc\fR; Tk_ItemCursorProc *\fIicursorProc\fR; Tk_ItemSelectionProc *\fIselectionProc\fR; Tk_ItemInsertProc *\fIinsertProc\fR; Tk_ItemDCharsProc *\fIdCharsProc\fR; Tk_ItemType *\fInextPtr\fR; .VS "8.7, TIP164" Tk_ItemRotateProc *\fIrotateProc\fR; .VE "8.7, TIP164" } \fBTk_ItemType\fR; .CE .PP The fields of a Tk_ItemType structure are described in more detail later in this manual entry. When \fBTk_CreateItemType\fR is called, its \fItypePtr\fR argument must point to a structure with all of the fields initialized |
︙ | |||
545 546 547 548 549 550 551 552 553 554 555 556 557 558 | 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | .CE .PP The \fIcanvas\fR and \fIitemPtr\fR arguments have the usual meaning, and \fIdeltaX\fR and \fIdeltaY\fR give the amounts that should be added to each x and y coordinate within the item. The type manager should adjust the item's coordinates and update the bounding box in the item's header. .SS ROTATEPROC .VS "8.7, TIP164" .PP \fItypePtr\->rotateProc\fR is invoked by Tk to rotate a canvas item during the \fBrotate\fR widget command. The procedure must match the following prototype: .PP .CS typedef void \fBTk_ItemRotateProc\fR( Tk_Canvas \fIcanvas\fR, Tk_Item *\fIitemPtr\fR, double \fIoriginX\fR, double \fIoriginY\fR, double \fIangleRad\fR); .CE .PP The \fIcanvas\fR and \fIitemPtr\fR arguments have the usual meaning. \fIoriginX\fR and \fIoriginY\fR specify an origin relative to which the item is to be rotated, and \fIangleRad\fR gives the anticlockwise rotation to be applied in radians. The item should adjust the coordinates of its control points so that where they used to have coordinates \fIx\fR and \fIy\fR, they will have new coordinates \fIx\(fm\fR and \fIy\(fm\fR, where .PP .CS \fIrelX\fR = \fIx\fR - \fIoriginX\fR \fIrelY\fR = \fIy\fR - \fIoriginY\fR \fIx\(fm\fR = \fIoriginX\fR + \fIrelX\fR \(mu cos(\fIangleRad\fR) + \fIrelY\fR \(mu sin(\fIangleRad\fR) \fIy\(fm\fR = \fIoriginY\fR \(mi \fIrelX\fR \(mu sin(\fIangleRad\fR) + \fIrelY\fR \(mu cos(\fIangleRad\fR) .CE .PP The control points for an item are not necessarily the coordinates provided to the item when it is created (or via the \fItypePtr\->coordProc\fR), but could instead be derived from them. \fIrotateProc\fR must also update the bounding box in the item's header. .PP Item types do not need to provide a \fItypePtr\->rotateProc\fR. If the \fItypePtr\->rotateProc\fR is NULL, the \fItypePtr\->coordProc\fR will be used instead to retrieve and update the list of coordinates. .VE "8.7, TIP164" .SS INDEXPROC .PP \fItypePtr\->indexProc\fR is invoked by Tk to translate a string index specification into a numerical index, for example during the \fBindex\fR widget command. It is only relevant for item types that support indexable text or coordinates; \fItypePtr\->indexProc\fR may be specified as NULL for non-textual |
︙ |
Changes to doc/canvas.n.
︙ | |||
216 217 218 219 220 221 222 | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | - - + + + + + + | It is possible to adjust the origin of the canvas coordinate system relative to the origin of the window using the \fBxview\fR and \fByview\fR widget commands; this is typically used for scrolling. Canvases do not support scaling or rotation of the canvas coordinate system relative to the window coordinate system. .PP |
︙ | |||
670 671 672 673 674 675 676 | 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | - + - | factor can also be given and the photo image will be enlarged. The image background will be filled with the canvas background colour. The canvas widget does not need to be mapped for this widget command to work, but at least one of it's ancestors must be mapped. This command returns an empty string. .TP \fIpathName \fBimove \fItagOrId index x y\fR |
︙ | |||
762 763 764 765 766 767 768 | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | - + - | Move each of the items given by \fItagOrId\fR in the canvas coordinate space by adding \fIxAmount\fR to the x-coordinate of each point associated with the item and \fIyAmount\fR to the y-coordinate of each point associated with the item. This command returns an empty string. .TP \fIpathName \fBmoveto \fItagOrId xPos yPos\fR |
︙ | |||
957 958 959 960 961 962 963 | 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | - + + + + + + + + + + + + + + + + + + + + + - + | Note: this command has no effect on window items. Window items always obscure other item types, and the stacking order of window items is determined by the \fBraise\fR command and \fBlower\fR command, not the \fBraise\fR widget command and \fBlower\fR widget command for canvases. .RE .TP \fIpathName \fBrchars \fItagOrId first last string\fR |
︙ | |||
1830 1831 1832 1833 1834 1835 1836 | 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 | - + - | \fB\-stipple\fR \fB\-activestipple\fR \fB\-disabledstipple\fR \fB\-state\fR \fB\-tags\fR .DE The following extra options are supported for text items: .TP \fB\-angle \fIrotationDegrees\fR |
︙ |
Changes to generic/tk.h.
︙ | |||
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 | 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 | + + | int height); typedef double (Tk_ItemPointProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double *pointPtr); typedef int (Tk_ItemAreaProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr); typedef int (Tk_ItemPostscriptProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int prepass); typedef void (Tk_ItemRotateProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRadians); typedef void (Tk_ItemScaleProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double scaleX, double scaleY); typedef void (Tk_ItemTranslateProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); #ifdef USE_OLD_CANVAS typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, |
︙ | |||
1113 1114 1115 1116 1117 1118 1119 | 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | + + - + | Tk_ItemInsertProc *insertProc; /* Procedure to insert something into an * item. */ Tk_ItemDCharsProc *dCharsProc; /* Procedure to delete characters from an * item. */ struct Tk_ItemType *nextPtr;/* Used to link types together into a list. */ Tk_ItemRotateProc *rotateProc; /* Procedure to rotate an item's coordinates |
︙ |
Changes to generic/tkCanvArc.c.
︙ | |||
210 211 212 213 214 215 216 217 218 219 220 221 222 223 | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | + + | static void ComputeArcOutline(Tk_Canvas canvas, ArcItem *arcPtr); static int HorizLineToArc(double x1, double x2, double y, double rx, double ry, double start, double extent); static int VertLineToArc(double x, double y1, double y2, double rx, double ry, double start, double extent); static void RotateArc(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad); /* * The structures below defines the arc item types by means of functions that * can be invoked by generic item code. */ Tk_ItemType tkArcType = { |
︙ | |||
237 238 239 240 241 242 243 | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | + - + | TranslateArc, /* translateProc */ NULL, /* indexProc */ NULL, /* icursorProc */ NULL, /* selectionProc */ NULL, /* insertProc */ NULL, /* dTextProc */ NULL, /* nextPtr */ RotateArc, /* rotateProc */ |
︙ | |||
1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 | 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | { ArcItem *arcPtr = (ArcItem *) itemPtr; arcPtr->bbox[0] = originX + scaleX*(arcPtr->bbox[0] - originX); arcPtr->bbox[1] = originY + scaleY*(arcPtr->bbox[1] - originY); arcPtr->bbox[2] = originX + scaleX*(arcPtr->bbox[2] - originX); arcPtr->bbox[3] = originY + scaleY*(arcPtr->bbox[3] - originY); ComputeArcBbox(canvas, arcPtr); } /* *-------------------------------------------------------------- * * RotateArc -- * * This function is called to rotate an arc by a given amount. * * Results: * None. * * Side effects: * The position of the arc is rotated by angleRad radians about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ static void RotateArc( Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad) { ArcItem *arcPtr = (ArcItem *) itemPtr; double newX, newY, oldX, oldY; /* * Compute the centre of the box, then rotate that about the origin. */ newX = oldX = (arcPtr->bbox[0] + arcPtr->bbox[2]) / 2.0; newY = oldY = (arcPtr->bbox[1] + arcPtr->bbox[3]) / 2.0; TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad), &newX, &newY); /* * Apply the translation to the box. */ arcPtr->bbox[0] += newX - oldX; arcPtr->bbox[1] += newY - oldY; arcPtr->bbox[2] += newX - oldX; arcPtr->bbox[3] += newY - oldY; /* * TODO: update the arc endpoints? */ ComputeArcBbox(canvas, arcPtr); } /* *-------------------------------------------------------------- * * TranslateArc -- |
︙ |
Changes to generic/tkCanvBmap.c.
︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | + + | Tk_Canvas canvas, struct Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); static void DeleteBitmap(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display); static void DisplayBitmap(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display, Drawable dst, int x, int y, int width, int height); static void RotateBitmap(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad); static void ScaleBitmap(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double scaleX, double scaleY); static void TranslateBitmap(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); /* |
︙ | |||
133 134 135 136 137 138 139 | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | + - + | TranslateBitmap, /* translateProc */ NULL, /* indexProc */ NULL, /* icursorProc */ NULL, /* selectionProc */ NULL, /* insertProc */ NULL, /* dTextProc */ NULL, /* nextPtr */ RotateBitmap, /* rotateProc */ |
︙ | |||
782 783 784 785 786 787 788 789 790 791 792 793 794 795 | 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; bmapPtr->x = originX + scaleX*(bmapPtr->x - originX); bmapPtr->y = originY + scaleY*(bmapPtr->y - originY); ComputeBitmapBbox(canvas, bmapPtr); } /* *-------------------------------------------------------------- * * RotateBitmap -- * * This function is called to rotate a bitmap's origin by a given amount. * * Results: * None. * * Side effects: * The position of the bitmap is rotated by angleRad radians about * (originX, originY), and the bounding box is updated in the generic * part of the item structure. * *-------------------------------------------------------------- */ static void RotateBitmap( Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad) { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad), &bmapPtr->x, &bmapPtr->y); ComputeBitmapBbox(canvas, bmapPtr); } /* *-------------------------------------------------------------- * * TranslateBitmap -- * * This function is called to move an item by a given amount. |
︙ |
Changes to generic/tkCanvImg.c.
︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | + + | Tk_Canvas canvas, struct Tk_Item *itemPtr, int argc, Tcl_Obj *const argv[]); static void DeleteImage(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display); static void DisplayImage(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display, Drawable dst, int x, int y, int width, int height); static void RotateImage(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad); static void ScaleImage(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double scaleX, double scaleY); static void TranslateImage(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); /* |
︙ | |||
122 123 124 125 126 127 128 | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | + - + | TranslateImage, /* translateProc */ NULL, /* indexProc */ NULL, /* icursorProc */ NULL, /* selectionProc */ NULL, /* insertProc */ NULL, /* dTextProc */ NULL, /* nextPtr */ RotateImage, /* rotateProc */ |
︙ | |||
753 754 755 756 757 758 759 760 761 762 763 764 765 766 | 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Tcl_AppendPrintfToObj(psObj, "%.15g %.15g translate\n", x, y); } return Tk_PostscriptImage(image, interp, canvasWin, ((TkCanvas *) canvas)->psInfo, 0, 0, width, height, prepass); } /* *-------------------------------------------------------------- * * RotateImage -- * * This function is called to rotate an image's origin by a given amount. * This does *not* rotate the contents of the image. * * Results: * None. * * Side effects: * The position of the image anchor is rotated by angleRad radians about * (originX, originY), and the bounding box is updated in the generic * part of the item structure. * *-------------------------------------------------------------- */ static void RotateImage( Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad) { ImageItem *imgPtr = (ImageItem *) itemPtr; TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad), &imgPtr->x, &imgPtr->y); ComputeImageBbox(canvas, imgPtr); } /* *-------------------------------------------------------------- * * ScaleImage -- * * This function is invoked to rescale an item. |
︙ |
Changes to generic/tkCanvLine.c.
︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | + + | Tcl_FreeProc **freeProcPtr); static int ParseArrowShape(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *recordPtr, int offset); static const char * PrintArrowShape(ClientData clientData, Tk_Window tkwin, char *recordPtr, int offset, Tcl_FreeProc **freeProcPtr); static void RotateLine(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad); static void ScaleLine(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double scaleX, double scaleY); static void TranslateLine(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); /* |
︙ | |||
235 236 237 238 239 240 241 | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | + - + | TranslateLine, /* translateProc */ GetLineIndex, /* indexProc */ NULL, /* icursorProc */ NULL, /* selectionProc */ LineInsert, /* insertProc */ LineDeleteCoords, /* dTextProc */ NULL, /* nextPtr */ RotateLine, /* rotateProc */ |
︙ | |||
1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 | 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } if (linePtr->lastArrowPtr != NULL) { for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { coordPtr[0] += deltaX; coordPtr[1] += deltaY; } } ComputeLineBbox(canvas, linePtr); } /* *-------------------------------------------------------------- * * RotateLine -- * * This function is called to rotate a line by a given amount about a * point. * * Results: * None. * * Side effects: * The position of the line is rotated by angleRad about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ static void RotateLine( 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. */ { LineItem *linePtr = (LineItem *) itemPtr; double *coordPtr; int i; double s = sin(angleRad), c = cos(angleRad); for (i = 0, coordPtr = linePtr->coordPtr; i < linePtr->numPoints; i++, coordPtr += 2) { TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]); } if (linePtr->firstArrowPtr != NULL) { for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]); } } if (linePtr->lastArrowPtr != NULL) { for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]); } } ComputeLineBbox(canvas, linePtr); } /* *-------------------------------------------------------------- * |
︙ |
Changes to generic/tkCanvPoly.c.
︙ | |||
172 173 174 175 176 177 178 179 180 181 182 183 184 185 | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | + + | Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj); static int PolygonToArea(Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr); 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); static void TranslatePolygon(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); /* |
︙ | |||
198 199 200 201 202 203 204 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | - + - + + - + | DisplayPolygon, /* displayProc */ TK_CONFIG_OBJS | TK_MOVABLE_POINTS, /* flags */ PolygonToPoint, /* pointProc */ PolygonToArea, /* areaProc */ PolygonToPostscript, /* postscriptProc */ ScalePolygon, /* scaleProc */ TranslatePolygon, /* translateProc */ |
︙ | |||
1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 | 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | */ badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * 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. |
︙ |
Changes to generic/tkCanvText.c.
︙ | |||
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | + + | Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj); static int TextToArea(Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr); static double TextToPoint(Tk_Canvas canvas, Tk_Item *itemPtr, double *pointPtr); static int TextToPostscript(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int prepass); static void RotateText(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad); static void TranslateText(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); /* * The structures below defines the rectangle and oval item types by means of * functions that can be invoked by generic item code. */ |
︙ | |||
195 196 197 198 199 200 201 | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | + - + | TranslateText, /* translateProc */ GetTextIndex, /* indexProc */ SetTextCursor, /* icursorProc */ GetSelText, /* selectionProc */ TextInsert, /* insertProc */ TextDeleteChars, /* dTextProc */ NULL, /* nextPtr */ RotateText, /* rotateProc */ |
︙ | |||
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | return TkIntersectAngledTextLayout(textPtr->textLayout, (int) ((rectPtr[0] + 0.5) - textPtr->drawOrigin[0]), (int) ((rectPtr[1] + 0.5) - textPtr->drawOrigin[1]), (int) (rectPtr[2] - rectPtr[0] + 0.5), (int) (rectPtr[3] - rectPtr[1] + 0.5), textPtr->angle); } /* *-------------------------------------------------------------- * * RotateText -- * * This function is called to rotate a text item by a given amount about a * point. Note that this does *not* rotate the text of the item. * * Results: * None. * * Side effects: * The position of the text anchor is rotated by angleRad about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ static void RotateText( Tk_Canvas canvas, /* Canvas containing item. */ Tk_Item *itemPtr, /* Item that is being rotated. */ double originX, double originY, double angleRad) /* Amount by which item is to be rotated. */ { TextItem *textPtr = (TextItem *) itemPtr; TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad), &textPtr->x, &textPtr->y); ComputeTextBbox(canvas, textPtr); } /* *-------------------------------------------------------------- * * ScaleText -- * * This function is invoked to rescale a text item. |
︙ |
Changes to generic/tkCanvUtil.c.
︙ | |||
1261 1262 1263 1264 1265 1266 1267 | 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 | - | Tk_CanvasSetOffset(canvas, outline->gc, tsoffset); tsoffset->xoffset += w; tsoffset->yoffset += h; return 1; } return 0; } |
︙ | |||
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 | 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | TranslateAndAppendCoords(canvPtr, a[i*2], a[i*2+1], outArr, i); } if (tempArr != staticSpace) { ckfree(tempArr); } return numOutput; } /* *-------------------------------------------------------------- * * TkRotatePoint -- * * Rotate a point about another point. The angle should be converted into * its sine and cosine before calling this function. * * Results: * None * * Side effects: * The point in (*xPtr,*yPtr) is updated to be rotated about * (originX,originY) by the amount given by the sine and cosine of the * angle to rotate. * *-------------------------------------------------------------- */ void TkRotatePoint( double originX, double originY, /* The point about which to rotate. */ double sine, double cosine, /* How much to rotate? */ double *xPtr, double *yPtr) /* The point to be rotated. (INOUT) */ { double x = *xPtr - originX; double y = *yPtr - originY; /* * Beware! The canvas coordinate space is flipped vertically, so rotations * go the "wrong" way with respect to mathematics. */ *xPtr = originX + x * cosine + y * sine; *yPtr = originY - x * sine + y * cosine; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkCanvWind.c.
︙ | |||
73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | + + | Tk_Canvas canvas, struct Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); static void DeleteWinItem(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display); static void DisplayWinItem(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display, Drawable dst, int x, int y, int width, int height); static void RotateWinItem(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad); static void ScaleWinItem(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double scaleX, double scaleY); static void TranslateWinItem(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); static int WinItemCoords(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, |
︙ | |||
126 127 128 129 130 131 132 | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | + - + | TranslateWinItem, /* translateProc */ NULL, /* indexProc */ NULL, /* cursorProc */ NULL, /* selectionProc */ NULL, /* insertProc */ NULL, /* dTextProc */ NULL, /* nextPtr */ RotateWinItem, /* rotateProc */ |
︙ | |||
907 908 909 910 911 912 913 914 915 916 917 918 919 920 | 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); } else { Tcl_DiscardInterpState(interpState); } Tcl_DecrRefCount(psObj); return result; } /* *-------------------------------------------------------------- * * RotateWinItem -- * * This function is called to rotate a window item by a given amount * about a point. Note that this does *not* rotate the window of the * item. * * Results: * None. * * Side effects: * The position of the window anchor is rotated by angleRad about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ static void RotateWinItem( Tk_Canvas canvas, /* Canvas containing item. */ Tk_Item *itemPtr, /* Item that is being rotated. */ double originX, double originY, double angleRad) /* Amount by which item is to be rotated. */ { WindowItem *winItemPtr = (WindowItem *) itemPtr; TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad), &winItemPtr->x, &winItemPtr->y); ComputeWindowBbox(canvas, winItemPtr); } /* *-------------------------------------------------------------- * * ScaleWinItem -- * * This function is invoked to rescale a window item. |
︙ |
Changes to generic/tkCanvas.c.
︙ | |||
237 238 239 240 241 242 243 244 245 246 247 248 249 250 | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | + + + | static int CanvasWidgetCmd(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv); static void CanvasWorldChanged(ClientData instanceData); static int ConfigureCanvas(Tcl_Interp *interp, TkCanvas *canvasPtr, int argc, Tcl_Obj *const *argv, int flags); static void DefaultRotateImplementation(TkCanvas *canvasPtr, Tk_Item *itemPtr, double x, double y, double angleRadians); static void DestroyCanvas(void *memPtr); static int DrawCanvas(Tcl_Interp *interp, ClientData clientData, Tk_PhotoHandle photohandle, int subsample, int zoom); static void DisplayCanvas(ClientData clientData); static void DoItem(Tcl_Obj *accumObj, Tk_Item *itemPtr, Tk_Uid tag); static void EventuallyRedrawItem(TkCanvas *canvasPtr, Tk_Item *itemPtr); |
︙ | |||
556 557 558 559 560 561 562 563 564 565 566 567 568 569 | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Tk_Item *itemPtr, double xDelta, double yDelta) { itemPtr->typePtr->translateProc((Tk_Canvas) canvasPtr, itemPtr, xDelta, yDelta); } static inline void ItemRotate( TkCanvas *canvasPtr, Tk_Item *itemPtr, double x, double y, double angleRadians) { if (itemPtr->typePtr->rotateProc != NULL) { itemPtr->typePtr->rotateProc((Tk_Canvas) canvasPtr, itemPtr, x, y, angleRadians); } else { DefaultRotateImplementation(canvasPtr, itemPtr, x, y, angleRadians); } } /* *-------------------------------------------------------------- * * DefaultRotateImplementation -- * * The default implementation of the rotation operation, used when items * do not provide their own version. * *-------------------------------------------------------------- */ static void DefaultRotateImplementation( TkCanvas *canvasPtr, Tk_Item *itemPtr, double x, double y, double angleRadians) { int objc, i, ok = 1; Tcl_Obj **objv, **newObjv; double *coordv; double s = sin(angleRadians); double c = cos(angleRadians); Tcl_Interp *interp = canvasPtr->interp; /* * Get the coordinates out of the item. */ if (ItemCoords(canvasPtr, itemPtr, 0, NULL) == TCL_OK && Tcl_ListObjGetElements(NULL, Tcl_GetObjResult(interp), &objc, &objv) == TCL_OK) { coordv = (double *) Tcl_Alloc(sizeof(double) * objc); for (i=0 ; i<objc ; i++) { if (Tcl_GetDoubleFromObj(NULL, objv[i], &coordv[i]) != TCL_OK) { ok = 0; break; } } if (ok) { /* * Apply the rotation. */ for (i=0 ; i<objc ; i+=2) { double px = coordv[i+0] - x; double py = coordv[i+1] - y; double nx = px * c - py * s; double ny = px * s + py * c; coordv[i+0] = nx + x; coordv[i+1] = ny + y; } /* * Write the coordinates back into the item. */ newObjv = (Tcl_Obj **) Tcl_Alloc(sizeof(Tcl_Obj *) * objc); for (i=0 ; i<objc ; i++) { newObjv[i] = Tcl_NewDoubleObj(coordv[i]); Tcl_IncrRefCount(newObjv[i]); } ItemCoords(canvasPtr, itemPtr, objc, newObjv); for (i=0 ; i<objc ; i++) { Tcl_DecrRefCount(newObjv[i]); } Tcl_Free((char *) newObjv); } Tcl_Free((char *) coordv); } /* * The interpreter result was (probably) modified above; reset it. */ Tcl_ResetResult(interp); } /* *-------------------------------------------------------------- * * Tk_CanvasObjCmd -- * * This function is invoked to process the "canvas" Tcl command. See the |
︙ | |||
742 743 744 745 746 747 748 | 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | - - - + + - - - + + + - - - + + - - + + + | int index; static const char *const optionStrings[] = { "addtag", "bbox", "bind", "canvasx", "canvasy", "cget", "configure", "coords", "create", "dchars", "delete", "dtag", "find", "focus", "gettags", "icursor", |
︙ | |||
1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 | 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 | + + + + + + + + + + + + + + + + + + + + + + + + | if (!(dontRedraw1 && dontRedraw2)) { Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr, x1, y1, x2, y2); EventuallyRedrawItem(canvasPtr, itemPtr); } itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; } break; } case CANV_ROTATE: { double x, y, angle; Tk_Canvas canvas = (Tk_Canvas) canvasPtr; if (objc != 6) { Tcl_WrongNumArgs(interp, 2, objv, "tagOrId x y angle"); result = TCL_ERROR; goto done; } if (Tk_CanvasGetCoordFromObj(interp, canvas, objv[3], &x) != TCL_OK || Tk_CanvasGetCoordFromObj(interp, canvas, objv[4], &y) != TCL_OK || Tcl_GetDoubleFromObj(interp, objv[5], &angle) != TCL_OK) { result = TCL_ERROR; goto done; } angle = angle * 3.1415927 / 180.0; FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) { EventuallyRedrawItem(canvasPtr, itemPtr); ItemRotate(canvasPtr, itemPtr, x, y, angle); EventuallyRedrawItem(canvasPtr, itemPtr); canvasPtr->flags |= REPICK_NEEDED; } break; } case CANV_SCALE: { double xOrigin, yOrigin, xScale, yScale; if (objc != 7) { Tcl_WrongNumArgs(interp, 2, objv, |
︙ |
Changes to generic/tkInt.h.
︙ | |||
1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 | 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 | + + + | MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp, ClientData clientData); MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr); MODULE_SCOPE void TkpCancelWarp(TkDisplay *dispPtr); MODULE_SCOPE int TkListCreateFrame(ClientData clientData, Tcl_Interp *interp, Tcl_Obj *listObj, int toplevel, Tcl_Obj *nameObj); MODULE_SCOPE void TkRotatePoint(double originX, double originY, double sine, double cosine, double *xPtr, double *yPtr); #ifdef _WIN32 #define TkParseColor XParseColor #else MODULE_SCOPE Status TkParseColor (Display * display, Colormap map, const char* spec, XColor * colorPtr); |
︙ |
Changes to generic/tkRectOval.c.
︙ | |||
144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | + + | Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); static int RectOvalToPostscript(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int prepass); static int RectToArea(Tk_Canvas canvas, Tk_Item *itemPtr, double *areaPtr); static double RectToPoint(Tk_Canvas canvas, Tk_Item *itemPtr, double *pointPtr); static void RotateRectOval(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad); static void ScaleRectOval(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double scaleX, double scaleY); static void TranslateRectOval(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); /* |
︙ | |||
176 177 178 179 180 181 182 | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | + - + | TranslateRectOval, /* translateProc */ NULL, /* indexProc */ NULL, /* icursorProc */ NULL, /* selectionProc */ NULL, /* insertProc */ NULL, /* dTextProc */ NULL, /* nextPtr */ RotateRectOval, /* rotateProc */ |
︙ | |||
200 201 202 203 204 205 206 | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | + - + | TranslateRectOval, /* translateProc */ NULL, /* indexProc */ NULL, /* cursorProc */ NULL, /* selectionProc */ NULL, /* insertProc */ NULL, /* dTextProc */ NULL, /* nextPtr */ RotateRectOval, /* rotateProc */ |
︙ | |||
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 | 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | && ((xDelta2 + yDelta1) < 1.0) && ((xDelta2 + yDelta2) < 1.0)) { return -1; } } return result; } /* *-------------------------------------------------------------- * * RotateRectOval -- * * This function is invoked to rotate a rectangle or oval item's * coordinates. It works by rotating a computed point in the centre of * the bounding box, NOT by rotating the corners of the bounding box. * * Results: * None. * * Side effects: * The position of the rectangle or oval is rotated by angleRad about * (originX, originY), and the bounding box is updated in the generic * part of the item structure. * *-------------------------------------------------------------- */ static void RotateRectOval( Tk_Canvas canvas, /* Canvas containing rectangle. */ Tk_Item *itemPtr, /* Rectangle to be scaled. */ double originX, double originY, /* Origin about which to rotate rect. */ double angleRad) /* Amount to scale in X direction. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; double newX, newY, oldX, oldY; /* * Compute the centre of the box, then rotate that about the origin. */ newX = oldX = (rectOvalPtr->bbox[0] + rectOvalPtr->bbox[2]) / 2.0; newY = oldY = (rectOvalPtr->bbox[1] + rectOvalPtr->bbox[3]) / 2.0; TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad), &newX, &newY); /* * Apply the translation to the box. */ rectOvalPtr->bbox[0] += newX - oldX; rectOvalPtr->bbox[1] += newY - oldY; rectOvalPtr->bbox[2] += newX - oldX; rectOvalPtr->bbox[3] += newY - oldY; ComputeRectOvalBbox(canvas, rectOvalPtr); } /* *-------------------------------------------------------------- * * ScaleRectOval -- * * This function is invoked to rescale a rectangle or oval item. |
︙ |
Changes to tests/canvas.test.
︙ | |||
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 | 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0}} } -cleanup { destroy .c image delete testimage } -result 1 destroy .c test canvas-21.1 {canvas rotate} -setup { pack [canvas .c] } -body { .c create line 50 50 50 100 100 100 .c rotate all 75 75 90 lmap c [.c coords all] {format %.2f $c} } -cleanup { destroy .c } -result {50.00 100.00 100.00 100.00 100.00 50.00} test canvas-21.2 {canvas rotate} -setup { pack [canvas .c] } -body { .c create line 50 50 50 100 100 100 .c rotate all 75 75 -10 lmap c [.c coords all] {format %.2f $c} } -cleanup { destroy .c } -result {54.72 46.04 46.04 95.28 95.28 103.96} test canvas-21.3 {canvas rotate: syntax} -setup { pack [canvas .c] } -body { .c rotate all 75 75 } -returnCodes error -cleanup { destroy .c } -result {wrong # args: should be ".c rotate tagOrId x y angle"} test canvas-21.4 {canvas rotate: syntax} -setup { pack [canvas .c] } -body { .c rotate all 75 75 123 123 } -returnCodes error -cleanup { destroy .c } -result {wrong # args: should be ".c rotate tagOrId x y angle"} test canvas-21.5 {canvas rotate: syntax} -setup { pack [canvas .c] } -body { .c rotate {!} 1 1 1 } -returnCodes error -cleanup { destroy .c } -result {missing tag in tag search expression} test canvas-21.6 {canvas rotate: syntax} -setup { pack [canvas .c] } -body { .c rotate all x 1 1 } -returnCodes error -cleanup { destroy .c } -result {bad screen distance "x"} test canvas-21.7 {canvas rotate: syntax} -setup { pack [canvas .c] } -body { .c rotate all 1 x 1 } -returnCodes error -cleanup { destroy .c } -result {bad screen distance "x"} test canvas-21.8 {canvas rotate: syntax} -setup { pack [canvas .c] } -body { .c rotate all 1 1 x } -returnCodes error -cleanup { destroy .c } -result {expected floating-point number but got "x"} test canvas-21.9 {canvas rotate: nothing to rotate} -setup { pack [canvas .c] } -body { .c rotate all 75 75 10 } -cleanup { destroy .c } -result {} test canvas-21.10 {canvas rotate: multiple things to rotate} -setup { pack [canvas .c] } -body { .c create line 50 50 50 100 -tag a .c create line 50 50 100 50 -tag b .c rotate all 75 75 45 list [lmap c [.c coords a] {format %.2f $c}] [lmap c [.c coords b] {format %.2f $c}] } -cleanup { destroy .c } -result {{39.64 75.00 75.00 110.36} {39.64 75.00 75.00 39.64}} test canvas-22.1 {canvas rotate: arc item rotation behaviour} -setup { pack [canvas .c] } -body { .c create arc 50 50 75 75 -start 45 -extent 90 .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {-start -extent} {.c itemcget all $o}] \ [.c bbox all] } -cleanup { destroy .c } -result {{50.00 125.00 75.00 150.00} {45.0 90.0} {52 123 73 140}} test canvas-22.2 {canvas rotate: bitmap item rotation behaviour} -setup { pack [canvas .c] } -body { .c create bitmap 50 50 -bitmap info -anchor se .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {-bitmap -anchor} {.c itemcget all $o}] \ [.c bbox all] } -cleanup { destroy .c } -result {{50.00 150.00} {info se} {42 129 50 150}} test canvas-22.3 {canvas rotate: image item rotation behaviour} -setup { pack [canvas .c] image create photo dummy -width 50 -height 50 } -body { .c create image 50 50 -image dummy -anchor se .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {-image -anchor} {.c itemcget all $o}] \ [.c bbox all] } -cleanup { destroy .c image delete dummy } -result {{50.00 150.00} {dummy se} {0 100 50 150}} test canvas-22.4 {canvas rotate: line item rotation behaviour} -setup { pack [canvas .c] } -body { .c create line 50 50 75 50 50 75 75 75 .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {} {.c itemcget all $o}] \ [.c bbox all] } -cleanup { destroy .c } -result {{50.00 150.00 50.00 125.00 75.00 150.00 75.00 125.00} {} {48 123 77 152}} test canvas-22.5 {canvas rotate: oval item rotation behaviour} -setup { pack [canvas .c] } -body { .c create oval 50 50 65 85 .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {} {.c itemcget all $o}] \ [.c bbox all] } -cleanup { destroy .c } -result {{60.00 125.00 75.00 160.00} {} {59 124 76 161}} test canvas-22.6 {canvas rotate: polygon item rotation behaviour} -setup { pack [canvas .c] } -body { .c create polygon 50 50 75 50 50 75 75 75 .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {} {.c itemcget all $o}] \ [.c bbox all] } -cleanup { destroy .c } -result {{50.00 150.00 50.00 125.00 75.00 150.00 75.00 125.00} {} {49 124 76 151}} test canvas-22.7 {canvas rotate: rectangle item rotation behaviour} -setup { pack [canvas .c] } -body { .c create rectangle 50 50 75 75 .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {} {.c itemcget all $o}] \ [.c bbox all] } -cleanup { destroy .c } -result {{50.00 125.00 75.00 150.00} {} {49 124 76 151}} test canvas-22.8 {canvas rotate: text item rotation behaviour} -setup { pack [canvas .c] } -body { .c create text 50 50 -text foo -angle 45 .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {-text -angle} {.c itemcget all $o}] # [.c bbox all] # No testing of text bounding box; fonts too variable! } -cleanup { destroy .c } -result {{50.00 150.00} {foo 45.0}} test canvas-22.9 {canvas rotate: window item rotation behaviour} -setup { pack [canvas .c] } -body { .c create window 50 50 -window [frame .c.f -width 25 -height 25] \ -anchor se .c rotate all 100 100 90 list [lmap c [.c coords all] {format %.2f $c}] \ [lmap o {} {.c itemcget all $o}] \ [.c bbox all] } -cleanup { destroy .c } -result {{50.00 150.00} {} {25 125 50 150}} # cleanup imageCleanup cleanupTests return # Local Variables: # mode: tcl |
︙ |