Tk Source Code

Check-in [320b73bd]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tests of rotation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-164
Files: files | file ages | folders
SHA3-256:320b73bd373cb3dc85b7405efcbd923f34f60bd19b8a647f1c1c0a1c82b00e9a
User & Date: dkf 2019-03-16 14:54:15
Context
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
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tests/canvas.test.

  1036   1036           {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \
  1037   1037           {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0}}
  1038   1038   } -cleanup {
  1039   1039       destroy .c
  1040   1040       image delete testimage
  1041   1041   } -result 1
  1042   1042   
         1043  +destroy .c
         1044  +test canvas-21.1 {canvas rotate} -setup {
         1045  +    pack [canvas .c]
         1046  +} -body {
         1047  +    .c create line 50 50 50 100 100 100
         1048  +    .c rotate all 75 75 90
         1049  +    lmap c [.c coords all] {format %.2f $c}
         1050  +} -cleanup {
         1051  +    destroy .c
         1052  +} -result {50.00 100.00 100.00 100.00 100.00 50.00}
         1053  +test canvas-21.2 {canvas rotate} -setup {
         1054  +    pack [canvas .c]
         1055  +} -body {
         1056  +    .c create line 50 50 50 100 100 100
         1057  +    .c rotate all 75 75 -10
         1058  +    lmap c [.c coords all] {format %.2f $c}
         1059  +} -cleanup {
         1060  +    destroy .c
         1061  +} -result {54.72 46.04 46.04 95.28 95.28 103.96}
         1062  +test canvas-21.3 {canvas rotate: syntax} -setup {
         1063  +    pack [canvas .c]
         1064  +} -body {
         1065  +    .c rotate all 75 75
         1066  +} -returnCodes error -cleanup {
         1067  +    destroy .c
         1068  +} -result {wrong # args: should be ".c rotate tagOrId x y angle"}
         1069  +test canvas-21.4 {canvas rotate: syntax} -setup {
         1070  +    pack [canvas .c]
         1071  +} -body {
         1072  +    .c rotate all 75 75 123 123
         1073  +} -returnCodes error -cleanup {
         1074  +    destroy .c
         1075  +} -result {wrong # args: should be ".c rotate tagOrId x y angle"}
         1076  +test canvas-21.5 {canvas rotate: syntax} -setup {
         1077  +    pack [canvas .c]
         1078  +} -body {
         1079  +    .c rotate {!} 1 1 1
         1080  +} -returnCodes error -cleanup {
         1081  +    destroy .c
         1082  +} -result {missing tag in tag search expression}
         1083  +test canvas-21.6 {canvas rotate: syntax} -setup {
         1084  +    pack [canvas .c]
         1085  +} -body {
         1086  +    .c rotate all x 1 1
         1087  +} -returnCodes error -cleanup {
         1088  +    destroy .c
         1089  +} -result {bad screen distance "x"}
         1090  +test canvas-21.7 {canvas rotate: syntax} -setup {
         1091  +    pack [canvas .c]
         1092  +} -body {
         1093  +    .c rotate all 1 x 1
         1094  +} -returnCodes error -cleanup {
         1095  +    destroy .c
         1096  +} -result {bad screen distance "x"}
         1097  +test canvas-21.8 {canvas rotate: syntax} -setup {
         1098  +    pack [canvas .c]
         1099  +} -body {
         1100  +    .c rotate all 1 1 x
         1101  +} -returnCodes error -cleanup {
         1102  +    destroy .c
         1103  +} -result {expected floating-point number but got "x"}
         1104  +test canvas-21.9 {canvas rotate: nothing to rotate} -setup {
         1105  +    pack [canvas .c]
         1106  +} -body {
         1107  +    .c rotate all 75 75 10
         1108  +} -cleanup {
         1109  +    destroy .c
         1110  +} -result {}
         1111  +test canvas-21.10 {canvas rotate: multiple things to rotate} -setup {
         1112  +    pack [canvas .c]
         1113  +} -body {
         1114  +    .c create line 50 50 50 100 -tag a
         1115  +    .c create line 50 50 100 50 -tag b
         1116  +    .c rotate all 75 75 45
         1117  +    list [lmap c [.c coords a] {format %.2f $c}] [lmap c [.c coords b] {format %.2f $c}]
         1118  +} -cleanup {
         1119  +    destroy .c
         1120  +} -result {{39.64 75.00 75.00 110.36} {39.64 75.00 75.00 39.64}}
         1121  +
         1122  +test canvas-22.1 {canvas rotate: arc item rotation behaviour} -setup {
         1123  +    pack [canvas .c]
         1124  +} -body {
         1125  +    .c create arc 50 50 75 75 -start 45 -extent 90
         1126  +    .c rotate all 100 100 90
         1127  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1128  +	[lmap o {-start -extent} {.c itemcget all $o}] \
         1129  +	[.c bbox all]
         1130  +} -cleanup {
         1131  +    destroy .c
         1132  +} -result {{50.00 125.00 75.00 150.00} {45.0 90.0} {52 123 73 140}}
         1133  +test canvas-22.2 {canvas rotate: bitmap item rotation behaviour} -setup {
         1134  +    pack [canvas .c]
         1135  +} -body {
         1136  +    .c create bitmap 50 50 -bitmap info -anchor se
         1137  +    .c rotate all 100 100 90
         1138  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1139  +	[lmap o {-bitmap -anchor} {.c itemcget all $o}] \
         1140  +	[.c bbox all]
         1141  +} -cleanup {
         1142  +    destroy .c
         1143  +} -result {{50.00 150.00} {info se} {42 129 50 150}}
         1144  +test canvas-22.3 {canvas rotate: image item rotation behaviour} -setup {
         1145  +    pack [canvas .c]
         1146  +    image create photo dummy -width 50 -height 50
         1147  +} -body {
         1148  +    .c create image 50 50 -image dummy -anchor se
         1149  +    .c rotate all 100 100 90
         1150  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1151  +	[lmap o {-image -anchor} {.c itemcget all $o}] \
         1152  +	[.c bbox all]
         1153  +} -cleanup {
         1154  +    destroy .c
         1155  +    image delete dummy
         1156  +} -result {{50.00 150.00} {dummy se} {0 100 50 150}}
         1157  +test canvas-22.4 {canvas rotate: line item rotation behaviour} -setup {
         1158  +    pack [canvas .c]
         1159  +} -body {
         1160  +    .c create line 50 50 75 50 50 75 75 75
         1161  +    .c rotate all 100 100 90
         1162  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1163  +	[lmap o {} {.c itemcget all $o}] \
         1164  +	[.c bbox all]
         1165  +} -cleanup {
         1166  +    destroy .c
         1167  +} -result {{50.00 150.00 50.00 125.00 75.00 150.00 75.00 125.00} {} {48 123 77 152}}
         1168  +test canvas-22.5 {canvas rotate: oval item rotation behaviour} -setup {
         1169  +    pack [canvas .c]
         1170  +} -body {
         1171  +    .c create oval 50 50 65 85
         1172  +    .c rotate all 100 100 90
         1173  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1174  +	[lmap o {} {.c itemcget all $o}] \
         1175  +	[.c bbox all]
         1176  +} -cleanup {
         1177  +    destroy .c
         1178  +} -result {{60.00 125.00 75.00 160.00} {} {59 124 76 161}}
         1179  +test canvas-22.6 {canvas rotate: polygon item rotation behaviour} -setup {
         1180  +    pack [canvas .c]
         1181  +} -body {
         1182  +    .c create polygon 50 50 75 50 50 75 75 75
         1183  +    .c rotate all 100 100 90
         1184  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1185  +	[lmap o {} {.c itemcget all $o}] \
         1186  +	[.c bbox all]
         1187  +} -cleanup {
         1188  +    destroy .c
         1189  +} -result {{50.00 150.00 50.00 125.00 75.00 150.00 75.00 125.00} {} {49 124 76 151}}
         1190  +test canvas-22.7 {canvas rotate: rectangle item rotation behaviour} -setup {
         1191  +    pack [canvas .c]
         1192  +} -body {
         1193  +    .c create rectangle 50 50 75 75
         1194  +    .c rotate all 100 100 90
         1195  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1196  +	[lmap o {} {.c itemcget all $o}] \
         1197  +	[.c bbox all]
         1198  +} -cleanup {
         1199  +    destroy .c
         1200  +} -result {{50.00 125.00 75.00 150.00} {} {49 124 76 151}}
         1201  +test canvas-22.8 {canvas rotate: text item rotation behaviour} -setup {
         1202  +    pack [canvas .c]
         1203  +} -body {
         1204  +    .c create text 50 50 -text foo -angle 45
         1205  +    .c rotate all 100 100 90
         1206  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1207  +	[lmap o {-text -angle} {.c itemcget all $o}]
         1208  +    # [.c bbox all]
         1209  +    # No testing of text bounding box; fonts too variable!
         1210  +} -cleanup {
         1211  +    destroy .c
         1212  +} -result {{50.00 150.00} {foo 45.0}}
         1213  +test canvas-22.9 {canvas rotate: window item rotation behaviour} -setup {
         1214  +    pack [canvas .c]
         1215  +} -body {
         1216  +    .c create window 50 50 -window [frame .c.f -width 25 -height 25] \
         1217  +	-anchor se
         1218  +    .c rotate all 100 100 90
         1219  +    list [lmap c [.c coords all] {format %.2f $c}] \
         1220  +	[lmap o {} {.c itemcget all $o}] \
         1221  +	[.c bbox all]
         1222  +} -cleanup {
         1223  +    destroy .c
         1224  +} -result {{50.00 150.00} {} {25 125 50 150}}
         1225  +
  1043   1226   # cleanup
  1044   1227   imageCleanup
  1045   1228   cleanupTests
  1046   1229   return
  1047   1230   
  1048   1231   # Local Variables:
  1049   1232   # mode: tcl
  1050   1233   # End: