Convert rectangle(s) to polygons, also refer to [Canvas Rotation] # Note: a new object ID will be assigned after conversion - may affect visibility order with respect # to other objects. # This may be prevented when conversion is part of a proc that saves canvas content to a file # (and then restores it - requires modified proc without $w delete and append "$w create poly" text # to file output). # This routine currently converts with the most common item attributes proc rect2poly {w item} { foreach {x0 y0 x1 y1} [$w coords $item] { set outline [$w itemcget $item -outline] set width [$w itemcget $item -width] if {!$width} { set outline {} } set fill [$w itemcget $item -fill] $w delete $item $w create poly $x0 $y0 $x0 $y1 $x1 $y1 $x1 $y0 -fill $fill -outline $outline -width $width } } proc rect2poly_all {w} { foreach item [$w find all] { puts $item if {[$w type $item]=="rectangle"} { rect2poly $w $item } } } # general notes: # -outline defaults to empty with polys, but black with rects # -width 0 yields 1 with polys, so making an outline absent, -outline must be "" # -fill is by default not present with rects, for rectangles, "" must be specified # poly creation with rect defaults: # .c create rectangle 5 50 150 150 -fill "" -outline black ---- [Category Graphics]