if 0 {[Richard Suchenwirth] 2003-02-15 - Regular polygons are convex shapes whose outline consists of straight segments of equal length, with equal angles between adjoining segments. Regular triangles and squares are simple examples. All corners of a r.p. are on a circle. Talking of circles, one bug of the Tk 8.4a2/WinCE port for the [iPAQ] is that oval canvas items (which in an enclosing square make circles) are not implemented, making porting things like [Nine Men Morris] or [trains3.tcl] a bit hard. I have no doubt that this will be fixed in later releases, but "I want it now"... Hence the following workaround to approximate ovals with polygons - just replace commands like $c create oval 0 0 50 50 ... with $c create poly [rp 0 0 50 50] ... where the rp function below computes a sequence of polygon points, starting at top center, that approximate an oval on the given enclosing rectangle - regular if it's a square, but also oblongly distorted for non-square rectangles, just as oval objects go. The degree (number of corners) may be specified as fifth argument, but defaults to a number which makes quite nice circles, e.g. 15 for a square side of 30 pixels. With this workaround in place, I could make a reasonable port of [Nine Men Morris] to the iPAQ. Dragging the men around is a bit slow in reaction (and risks scratches on the little touch screen), and I had to disable the snap-in-place code, but still it's a nice addition to the games collection ;-) ---- [KPV] How about generalizing this to work as a replacement for the arc command? [KPV] I just went and did it, see [Regular Polygons 2]. } proc rp {x0 y0 x1 y1 {n 0}} { set xm [expr {($x0+$x1)/2.}] set ym [expr {($y0+$y1)/2.}] set rx [expr {$xm-$x0}] set ry [expr {$ym-$y0}] if {$n==0} { set n [expr {round(($rx+$ry)*0.5)}] } set step [expr {atan(1)*8/$n}] set res "" set th [expr {atan(1)*6}] ;#top for {set i 0} {$i<$n} {incr i} { lappend res \ [expr {$xm+$rx*cos($th)}] \ [expr {$ym+$ry*sin($th)}] set th [expr {$th+$step}] } set res } if 0 { [http://mini.net/files/polygons.jpg] Finally, a demo as usual, which shows regular 3..8-gons and a circle approximated as a 15-gon:} if {[file tail [info script]]==[file tail $argv0]} { pack [canvas .c -width 240 -height 40] set x 0 set x1 32 foreach n {3 4 5 6 7 8 0} { .c create poly [rp $x 2 $x1 34 $n] -fill red -outline black incr x 34; incr x1 34 } } ---- [http://mini.net/files/9mm_ce.jpg] See [Traffic lights] for another use. ---- [Category Polygon] ----------- [http://ganzao.68l.com 干燥设备] [http://ganzao.68l.com/map.htm 列表] [http://ganzao.68l.com/index.htm 干燥设备] [http://ganzao.68l.com/ganzao.htm 干燥机] [http://ganzao.68l.com/liuhecai/liuhecai.htm 六合彩] [http://ganzao.68l.com/liuhecai/liuhecai518.htm 香港六合彩] [http://ganzao.68l.com/tuliao/tuliao.htm 涂料] [http://ganzao.68l.com/tuliao/tuliaojieshao.htm 绿色涂料] [http://ganzao.68l.com/dengju/dengju.htm 灯具] [http://ganzao.68l.com/cryp/chengrenyongping.htm 成人用品] [http://ganzao.68l.com/cryp/cryp1.htm 成人用品] [http://ganzao.68l.com/sljx/suliaojixie.htm 塑料机械] [http://ganzao.68l.com/jiansuji/jiansuji.htm 减速机] [http://ganzao.68l.com/wajueji/wajueji.htm 挖掘机] [http://ganzao.68l.com/yimin/yimin.htm 移民] [http://ganzao.68l.com/tanhuang/tanhuang.htm 弹簧]