---- [WikiDbImage rotatext.jpg] [Tom Krehbiel] shared the following interesting code in the [Tcl chatroom], which may display a large E in various rotation angles (X only, not on all Linuxes...): tomk: Are you aware that it is possible to rotate single character in a Tk canvas? kennykb: Rotate single char in Tk canvas? How? tomk: I have some code that someone (smarter than me) posted. I don't remember when or who. You want me to sent you a copy? kennykb: Sure, glad to look at it. This supposed to be Tcl code? Or is someone changing the canvas implementation? ---- proc rotmatrix {size angle} { set size [expr {double($size)}] set angle [expr {double($angle)*acos(0.0)/90.0}]; # In radians set c [expr {$size*cos($angle)}] set s [expr {$size*sin($angle)}] # Due to Tk's XLFD (X Logical Font Description) # parser, we need to round values set s [format "\[%.f %.f %.f %.f\]" $c [expr {-$s}] $s $c] regsub -all -- "-" $s ~ s return $s } pack [scrollbar .vs -orient vertical -command {.c yview}] -side right -fill y pack [scrollbar .hs -orient horizontal -command {.c xview}] -side bottom -fill x pack [canvas .c -bg white -xscrollcommand {.hs set} -yscrollcommand {.vs set}]\ -side left -expand 1 -fill both set nb 16 set size 24 set size 64 set text "The Quick Brown Fox jumps over the Lazy Black Dog" set text "E" .c configure -scrollregion [list -1000 0 1000 [expr {$size*$nb*2}]] set x 100 for {set i 0} {$i < 16} {incr i} { set y [expr {10+$i*$size*2}] set angle [expr {360.0*$i/$nb}] .c create text $x $y -text [format "%.1f½½° " $angle] -anchor ne -font \ -adobe-times-medium-r-*-*-$size-*-*-*-*-*-*-* .c create text $x $y -text $text -anchor nw -font \ -adobe-times-medium-r-*-*-[rotmatrix $size $angle]-*-*-*-*-*-*-* .c create rectangle [expr {$x-2}] [expr {$y-2}] [expr {$x+2}] [expr {$y+2}]\ -outline black -fill red } ---- suchenwi: WOW! YES! tomk: I added the 64 font size and the text "E". If you remove them you get a string version. kennykb Guys: Before you get too excited, this is Unix-only and not supported by every X server. suchenwi: Works here on Solaris via Reflection, but not native on PC - there the E is only scaled smaller. But it's definitely only recommendable for a single letter... bschwarz: doesn't work on linux kennykb: The functionality is X, mostly. The comment about Tk's XLFD parser has to do with whether Tk will recognize the string as an XLFD or a Tk font name. trb: works on my linux: 2.2.18. XFree86 v 3360 tk 8.3 ---- ''[DKF]:'' Note that the above does not work with an IRIX Xserver. ---- The [BLT] extension can also [rotate text on a canvas] ---- [Category Example] - [Category Graphics]