Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Falling+Marbles?V=19
QUERY_STRINGV=19
CONTENT_TYPE
DOCUMENT_URI/revision/Falling+Marbles
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.100.194
REMOTE_PORT9842
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR18.217.4.206
HTTP_CF_RAY879f4776de5349f4-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP18.217.4.206
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit {Falling Marbles} \[Keith\ Vetter\]\ 2003-04-29\ :\ here's\ fun\ little\ animation\ of\ marbles\ cascading\ndown\ a\ peg\ board.\ The\ images\ for\ the\ marbles\ come\ from\ \[gifBalls\].\n\n\[http://www.tcl.tk/starkits/marbles.jpg\]\n\n\[KPV\]\ 2003-04-30\ :\ put\ up\ a\ new\ version\ with\ better\ resizing\ behavior,\ sound\nand\ more\ controls.\n\n\[KPV\]\ 2003-05-02\ :\ added\ no\ ramp\ mode\n\n----\n\n\[TV\]\ Good\ visual\ effect.\ Makes\ me\ wonder\ about\ scaling,\ both\ the\ graphics,\ and\ the\ machine\ horsepower\ versus\ update\ rate\ or\ bounce\ increment.\ And\ colliding\ balls.\n\n\[KPV\]\ Thanks.\ As\ to\ scaling\ issues,\ let's\ first\ take\ horsepower.\ \n\[Creating\ an\ animated\ display\]\ discusses\ this\ issue--basically\neach\ frame\ has\ an\ allotted\ amount\ of\ time\ to\ complete\ and,\ by\ using\ the\ \[after\]\ \ncommand,\ the\ next\ frame\ is\ not\ drawn\ until\ that\ time\ has\ elapsed.\ So\ a\ slow\nmachine\ will\ consume\ more\ of\ each\ time\ allotment\ while\ fast\ machines\ will\ \nconsume\ less,\ but,\ theoretically,\ they\ both\ should\ produce\ the\ same\ display.\n\nThe\ way\ to\ handle\ graphic\ scaling\ is\ to\ use\ Newtonian\ physics\ with\ gravity\nacceleration\ and\ velocity\ to\ compute\ a\ ball's\ path\ through\ the\ pegs.\ This\nisn't\ that\ hard,\ but\ since\ my\ ball\ GIF\ images\ don't\ scale\ nicely,\ I\ just\ \nfaked\ it--2\ steps\ up\ and\ 5\ steps\ down.\n----\n\[escargo\]\ -\ I\ was\ noticing\ that\ the\ \"Birth\ Rate\"\ was\ not\ acting\ the\ way\ I\ was\ expecting.\nLooking\ at\ the\ code\ I\ noticed\ the\ following\ things\ in\ the\ NewBirth\ proc.\n\n\ \ \ *\ The\ ''val''\ parameter\ is\ not\ used.\n\ \ \ *\ The\ ''rate''\ variable\ is\ inverted\ relative\ to\ the\ scale\ widget\ value\ (which\ means\ at\ the\ very\ least\ that\ it\ has\ the\ wrong\ name).\n\ \ \ *\ The\ greater\ the\ speed\ setting,\ the\ lower\ the\ delay\ (which\ is\ good).\n\nMy\ user\ expectation\ is\ that\ changing\ the\ \"Birth\ Rate\"\ should\ result\ in\ something\ like\nlinear\ changes\ in\ the\ birth\ rate.\ \ That's\ not\ what\ I\ observe.\ \ Am\ I\ missing\ something?\n\n\[KPV\]\ -\ My\ intent\ was\ that\ birth\ rate\ is\ births\ per\ unit\ time\ meaning\nthat\ a\ larger\ value\ results\ in\ more\ balls\ coming\ out.\ That\ is\ why\ the\nscale\ value\ gets\ inverted.\ The\ result\ should\ be\ linear--doubling\ the\ \nvalue\ means\ that\ twice\ as\ many\ balls\ coming\ out--but\ I\ do\ add\ in\ a\ random\ndelay\ that\ may\ skew\ your\ perception.\n\nThe\ reason\ why\ the\ ''val''\ parameter\ isn't\ used\ by\ NewBirth\nis\ partly\ historical\ and\ partly\ a\ lost\ feature\ (oops).\ Originally\ NewBirth\ntook\ no\ parameter\ but\ then\ I\ thought\ it\ would\ be\ nice\ if\ changing\nthe\ birth\ rate\ took\ effect\ immediately.\ So\ I\ set\ the\ scale's\ command\ to\ be\nNewBirth\ but\ that\ meant\ that\ NewBirth\ had\ to\ take\ a\ parameter.\ That\ new\ parameter\nchange\ got\ in\ the\ final\ version\ but\ somehow\ the\ added\ command\ to\ the\ scale\nwidget\ got\ lost\ (I've\ now\ added\ it\ in).\n\n\[escargo\]\ Even\ the\ new\ version\ seems\ like\ a\ very\ nonlinear\ frequency\ change\ between\ndifferent\ \"Birth\ Rate\"\ values.\ \ (Pehaps\ the\ only\ way\ to\ find\ out\ would\ be\ to\ add\na\ field\ that\ showed\ internal\ values.\ \ I\ don't\ know\ if\ the\ problem\ is\ perceptual\n(rate\ really\ is\ linear)\ or\ procedural\ (rate\ really\ isn't\ linear).\n\n----\n======\n##+##########################################################################\n#\n#\ Falling\ Marbles\n#\ by\ Keith\ Vetter,\ April\ 2003\n#\ KPV\ Apr\ 30,\ 2003\ -\ better\ resizing\ behavior,\ sound,\ more\ controls\n#\ KPV\ May\ \ 2,\ 2003\ -\ added\ no\ ramp\ mode\n#\n\npackage\ require\ Tk\n\narray\ set\ S\ \{title\ \"Falling\ Marbles\"\ top\ 70\ bottom\ 20\ xspacing\ 20\ yspacing\ 30\n\ \ \ \ pegsize\ 3\ bnum\ 0\ stop\ 1\ bias\ 0\ speed\ 5\ sound\ 0\ auto\ 1\ birth\ 96\ ramp\ 1\}\n\nset\ S(psteps)\ 7\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Steps\ falling\ between\ pegs\nset\ S(rsteps)\ 15\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Steps\ rolling\ down\ ramp\nset\ S(dsteps)\ 3\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Steps\ dropping\ to\ first\ peg\nset\ S(hsteps)\ 10\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Steps\ holding\ still\n\nproc\ DoDisplay\ \{\}\ \{\n\ \ \ \ global\ S\n\n\ \ \ \ #\ see\ http://wiki.tcl.tk/gifBalls\n\ \ \ \ set\ ball(red)\ \{R0lGODlhFAAPAPMPAAAAADgFD00CEGoDGHMTJ21ZXZISK6USL7MoRJ1aZ\n\ \ \ \ \ \ \ \ 9IzUvRUdNVAXscbPv9ylKqcniH5BAEAAAAALAAAAAAUAA8AAARwEMgpX7qPavrQ+YdBZ\n\ \ \ \ \ \ \ \ Nv0HIDCKE04kNvZMEvNeIMAU8mhLI7gQuEqlAwHWtCxYLgIMeRvOTwQBoHS4ICg2RCGX\n\ \ \ \ \ \ \ \ HZDQCIUaPBVMNYkBgZkSCQ2lgSDAWGfZwd2HAJ4fX6AGg9sggGLhiUPBZCNJZMaEQA7\}\n\ \ \ \ set\ ball(yellow)\ \{R0lGODlhFAAPAPMPAAAAADExBD09Kk5OAmtrDFNTKmxsWImJFLCwM5\n\ \ \ \ \ \ \ \ mZJaCgUsXFONPTUvb2ceXlWKennCH5BAEAAAAALAAAAAAUAA8AAARqEMgpX1Lq0U3t+Q\n\ \ \ \ \ \ \ \ dBaNz0HAmyIEk4kNyZLI7DMC3xlsqBOI0gA+EylAgpoJCoK8QIPkbQxhwEjqjFbZgQWY\n\ \ \ \ \ \ \ \ /QFILlClw5hoEI5LUaSwO1SBc3wzaPgCC+NwfuMX5+AoAlAA8GBQaFho0UEQA7\}\n\ \ \ \ set\ ball(green)\ \{R0lGODlhFAAPAPQAAAAAAAA4BwBNCgBqEgBzE0ZtTACSEwClFgqzJj+d\n\ \ \ \ \ \ \ \ TADHIQ/SKRzVOyv0RUf/bH+qgwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n\ \ \ \ \ \ \ \ AAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAUAA8AAAV2ICSO4pOcD6mSD3K8h0Gk6/\n\ \ \ \ \ \ \ \ gc0MIsSjzQq5uC0SgyXAMBkJQ4LBqOaGPhK9QMB2LU0WD4CEHsczs9EAaB2uCAIBoRhmR\n\ \ \ \ \ \ \ \ 6RcAiFnj4WTBXJQYGWDEyclY1AgMDBIuJfAFLLAKIjY6QKg98kgGbljUPBaCdNaMqIQA7\}\n\n\ \ \ \ wm\ title\ .\ \$S(title)\n\ \ \ \ pack\ \[frame\ .ctrl\ -relief\ ridge\ -bd\ 2\ -padx\ 5\ -pady\ 5\]\ \\\n\ \ \ \ \ \ \ \ -side\ right\ -fill\ both\ -ipady\ 5\n\ \ \ \ pack\ \[frame\ .screen\ -bd\ 2\ -relief\ raised\]\ -side\ left\ -fill\ both\ -expand\ 1\n\n\ \ \ \ canvas\ .c\ -borderwidth\ 0\ -height\ 500\ -width\ 600\ \\\n\ \ \ \ \ \ \ \ -highlightthickness\ 0\ -scrollregion\ \{-300\ 0\ 300\ 500\}\n\n\ \ \ \ bind\ all\ <Alt-c>\ \{console\ show\}\n\n\ \ \ \ DoCtrlFrame\n\ \ \ \ foreach\ b\ \{red\ yellow\ green\}\ num\ \{0\ 1\ 2\}\ \{\n\ \ \ \ \ \ \ \ image\ create\ photo\ ::img::ball(\$num)\ -data\ \$ball(\$b)\n\ \ \ \ \}\n\n\ \ \ \ set\ S(bw)\ \[image\ width\ ::img::ball(0)\]\n\ \ \ \ set\ S(bh)\ \[image\ height\ ::img::ball(0)\]\n\n\ \ \ \ bind\ .c\ <Configure>\ \{\n\ \ \ \ \ \ \ \ DrawPegs\n\ \ \ \ \ \ \ \ DrawSums\n\ \ \ \ \ \ \ \ DrawRamps\n\ \ \ \ \ \ \ \ DoSounds\n\ \ \ \ \ \ \ \ ReCenter\ %W\ %h\ %w\n\ \ \ \ \ \ \ \ Go\n\ \ \ \ \}\n\ \ \ \ pack\ .c\ -in\ .screen\ -side\ left\ -fill\ both\ -expand\ 1\n\}\nproc\ DoCtrlFrame\ \{\}\ \{\n\ \ \ \ button\ .go\ -text\ \"Go\"\ -command\ Go\ -bd\ 4\n\ \ \ \ .go\ configure\ -font\ \"\[font\ actual\ \[.go\ cget\ -font\]\]\ -weight\ bold\"\n\ \ \ \ button\ .clear\ -text\ \"Clear\"\ -command\ Clear\ -bd\ 4\ -font\ \[.go\ cget\ -font\]\n\ \ \ \ button\ .new\ -text\ \"New\ Ball\"\ -command\ CreateBall\ -bd\ 4\ -font\ \[.go\ cget\ -font\]\n\ \ \ \ checkbutton\ .sound\ -text\ \"Sound\"\ -relief\ raised\ -bd\ 4\ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ -variable\ S(sound)\ -padx\ 10\ -anchor\ w\ -font\ \[.go\ cget\ -font\]\n\ \ \ \ checkbutton\ .auto\ -text\ \"Auto\ Ball\"\ -relief\ raised\ -bd\ 4\ -command\ Birth\ \\\n\ \ \ \ \ \ \ \ -variable\ S(auto)\ -padx\ 10\ -anchor\ w\ -font\ \[.go\ cget\ -font\]\n\ \ \ \ checkbutton\ .ramp\ -text\ \"Ramp\"\ -relief\ raised\ -bd\ 4\ -command\ DrawRamps\ \\\n\ \ \ \ \ \ \ \ -variable\ S(ramp)\ -padx\ 10\ -anchor\ w\ -font\ \[.go\ cget\ -font\]\n\n\ \ \ \ button\ .about\ -text\ \"About\"\ -font\ \[.go\ cget\ -font\]\ -command\ \\\n\ \ \ \ \ \ \ \ \[list\ tk_messageBox\ -message\ \"\$::S(title)\\nby\ Keith\ Vetter,\ April\ 2003\"\]\n\ \ \ \ scale\ .speed\ -orient\ h\ -from\ 1\ -to\ 10\ -font\ \[.go\ cget\ -font\]\ \\\n\ \ \ \ \ \ \ \ -variable\ S(speed)\ -bd\ 2\ -relief\ ridge\ -showvalue\ 1\ -label\ Speed\n\ \ \ \ scale\ .birth\ -orient\ h\ -from\ 3\ -to\ 100\ -font\ \[.go\ cget\ -font\]\ \\\n\ \ \ \ \ \ \ \ -variable\ S(birth)\ -bd\ 2\ -relief\ ridge\ -showvalue\ 1\ -label\ \"Birth\ Rate\"\ \\\n\ \ \ \ \ \ \ \ -command\ NewBirth\n\ \ \ \ scale\ .bias\ -orient\ h\ -from\ -10\ -to\ 10\ -font\ \[.go\ cget\ -font\]\ \\\n\ \ \ \ \ \ \ \ -variable\ S(bias)\ -bd\ 2\ -relief\ ridge\ -showvalue\ 1\ -label\ \"Bias\"\n\n\ \ \ \ grid\ .go\ -in\ .ctrl\ -sticky\ ew\ -row\ 0\n\ \ \ \ grid\ .clear\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ .new\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ rowconfigure\ .ctrl\ 10\ -minsize\ 10\n\ \ \ \ grid\ .sound\ -in\ .ctrl\ -sticky\ ew\ -row\ 11\n\ \ \ \ grid\ .auto\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ .ramp\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ rowconfigure\ .ctrl\ 30\ -minsize\ 20\n\ \ \ \ grid\ .speed\ -in\ .ctrl\ -sticky\ ew\ -row\ 31\n\ \ \ \ grid\ .birth\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ .bias\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ rowconfigure\ .ctrl\ 50\ -weight\ 1\n\ \ \ \ grid\ .about\ -in\ .ctrl\ -sticky\ ew\ -row\ 100\n\}\nproc\ DrawPegs\ \{\}\ \{\n\ \ \ \ global\ S\ PEG\ SUMS\n\n\ \ \ \ .c\ delete\ peg\n\ \ \ \ lassign\ \[.c\ cget\ -scrollregion\]\ X0\ Y0\ X1\ Y1\n\n\ \ \ \ set\ top\ \[expr\ \{\$Y0\ +\ \$S(top)\}\]\n\ \ \ \ set\ bottom\ \[expr\ \{\$Y1\ -\ \$S(bottom)\}\]\n\ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ 50\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ \ \ set\ y\ \[expr\ \{\$top\ +\ \$row\ *\ \$S(yspacing)\}\]\n\ \ \ \ \ \ \ \ #if\ \{\$y\ >\ \$bottom\}\ break\n\n\ \ \ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ 50\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ x\ \[expr\ \{\$col\ *\ \$S(xspacing)\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ set\ PEG(\$col,\$row)\ \[list\ \$x\ \$y\]\n\ \ \ \ \ \ \ \ \ \ \ \ set\ PEG(-\$col,\$row)\ \[list\ -\$x\ \$y\]\n\ \ \ \ \ \ \ \ \ \ \ \ #if\ \{\$x\ >\ \$X1\}\ continue\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{(\$row\ &\ 1)\ &&\ !(\$col\ &\ 1)\}\ continue\ \;#\ Odd\ row,\ even\ column\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{!(\$row\ &\ 1)\ &&\ (\$col\ &\ 1)\}\ continue\ \;#\ Even\ row,\ odd\ column\n\n\ \ \ \ \ \ \ \ \ \ \ \ .c\ create\ oval\ \[bbox\ \$x\ \$y\ \$S(pegsize)\]\ -tag\ peg\ -fill\ black\n\ \ \ \ \ \ \ \ \ \ \ \ .c\ create\ oval\ \[bbox\ -\$x\ \$y\ \$S(pegsize)\]\ -tag\ peg\ -fill\ black\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\n\ \ \ \ .c\ create\ rect\ 0\ 0\ 0\ 0\ -tag\ sum\ -fill\ \[.c\ cget\ -bg\]\ -outline\ \{\}\n\ \ \ \ #\ Sums\ text\n\ \ \ \ set\ y\ \[expr\ \{\$Y1\ -\ 2\}\]\n\ \ \ \ set\ font\ \{\{Times\ Roman\}\ 8\ bold\}\n\ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ 50\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ set\ x\ \[expr\ \{\$col\ *\ \$S(xspacing)\}\]\n\ \ \ \ \ \ \ \ .c\ create\ text\ \$x\ \$y\ -tag\ e\$col\ -font\ \$font\ -anchor\ s\n\ \ \ \ \ \ \ \ .c\ create\ text\ -\$x\ \$y\ -tag\ e-\$col\ -font\ \$font\ -anchor\ s\n\ \ \ \ \ \ \ \ set\ SUMS(\$col)\ \[set\ SUMS(-\$col)\ \"\"\]\n\ \ \ \ \}\n\ \ \ \ trace\ variable\ SUMS\ w\ TraceSums\n\}\nproc\ DrawSums\ \{\}\ \{\n\ \ \ \ global\ S\ PEG\n\n\ \ \ \ lassign\ \[.c\ cget\ -scrollregion\]\ X0\ Y0\ X1\ Y1\n\ \ \ \ set\ bottom\ \[expr\ \{\$Y1\ -\ \$S(bottom)\}\]\n\n\ \ \ \ for\ \{set\ row\ 0\}\ \{1\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ \ \ lassign\ \$PEG(0,\$row)\ x\ y\n\ \ \ \ \ \ \ \ if\ \{\$y\ >\ \$bottom\}\ break\n\ \ \ \ \}\n\ \ \ \ set\ S(rows)\ \$row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Number\ of\ visible\ rows\n\ \ \ \ set\ S(cols)\ \[expr\ \{int(double(\$X1)\ /\ \$S(xspacing))\ |\ 1\}\]\n\ \ \ \ .c\ coords\ sum\ -999\ \[expr\ \{\$y\ -\ \$S(pegsize)\}\]\ 999\ \$Y1\ \;#\ Blank\ out\ bottom\n\n\ \ \ \ #\ Reposition\ counters\n\ \ \ \ set\ y\ \[expr\ \{\$Y1\ -\ 2\}\]\n\ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ 50\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ set\ x\ \[expr\ \{\$col\ *\ \$S(xspacing)\}\]\n\ \ \ \ \ \ \ \ .c\ coords\ e\$col\ \$x\ \$y\n\ \ \ \ \ \ \ \ .c\ coords\ e-\$col\ -\$x\ \$y\n\ \ \ \ \}\n\}\nproc\ DrawRamps\ \{\}\ \{\n\ \ \ \ global\ S\ B\n\n\ \ \ \ .c\ delete\ ramp\ door\n\ \ \ \ foreach\ a\ \[array\ names\ B\ *,where\]\ \{\n\ \ \ \ \ \ \ \ if\ \{\$B(\$a)\ ==\ \"ramp\"\ ||\ \$B(\$a)\ ==\ \"hold\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ id\ \[lindex\ \[split\ \$a\ \",\"\]\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ array\ unset\ B\ \$id,*\n\ \ \ \ \ \ \ \ \ \ \ \ .c\ delete\ \$id\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ if\ \{!\ \$S(ramp)\}\ return\n\n\ \ \ \ lassign\ \[.c\ cget\ -scrollregion\]\ X0\ Y0\ X1\ Y1\n\ \ \ \ set\ x0\ \$X1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y0\ \[expr\ \{\$Y0\ +\ \$S(bh)\}\]\n\ \ \ \ set\ x1\ \[expr\ \{\$S(bw)\ /\ 2\}\]\ \;\ set\ y1\ \[expr\ \{\$Y0\ +\ \$S(top)\ -\ 3*\$S(bh)\}\]\n\ \ \ \ set\ x2\ \$x1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y2\ \[expr\ \{\$y1\ +\ \$S(bh)\}\]\n\ \ \ \ set\ x3\ \$x0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y3\ \$y2\n\ \ \ \ set\ x4\ 5000\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y4\ \$y3\n\ \ \ \ set\ x5\ \$x4\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y5\ \$y0\n\ \ \ \ .c\ create\ poly\ \$x0\ \$y0\ \$x1\ \$y1\ \$x2\ \$y2\ \$x3\ \$y3\ \$x4\ \$y4\ \$x5\ \$y5\ -tag\ ramp\n\ \ \ \ .c\ create\ poly\ -\$x0\ \$y0\ -\$x1\ \$y1\ -\$x2\ \$y2\ -\$x3\ \$y3\ -\$x4\ \$y4\ -\$x5\ \$y5\ \\\n\ \ \ \ \ \ \ \ -tag\ ramp\n\n\ \ \ \ set\ S(rsteps)\ \[expr\ \{\$X1\ <\ 20\ ?\ 1\ :\ \$X1\ /\ 20\}\]\n\ \ \ \ set\ S(entry,0)\ \[list\ \[expr\ \{\$X0\ +\ \$S(bw)\ /\ 2.0\}\]\ \[expr\ \{\$Y0\ +\ \$S(bh)\ +\ 2\}\]\]\n\ \ \ \ set\ S(entry,1)\ \[list\ \[expr\ \{\$X1\ -\ \$S(bw)\ /\ 2.0\}\]\ \[expr\ \{\$Y0\ +\ \$S(bh)\ +\ 2\}\]\]\n\ \ \ \ set\ S(drop,x)\ 0\n\ \ \ \ set\ S(drop,y)\ \[expr\ \{\$y1\ +\ 3\}\]\n\n\ \ \ \ set\ x\ \[expr\ \{\$X1\ -\ \$S(bw)\}\]\ \;\ set\ y\ \[expr\ \{\$Y0\ +\ \$S(bh)\}\]\n\ \ \ \ .c\ create\ oval\ \$x\ \$Y0\ \$X1\ \$y\ -tag\ door\ -fill\ red\n\ \ \ \ .c\ create\ oval\ \[expr\ \{-1*\$x\}\]\ \$Y0\ \$X0\ \$y\ -tag\ door\ -fill\ red\n\}\nproc\ TraceSums\ \{var1\ var2\ op\}\ \{\n\ \ \ \ .c\ itemconfig\ e\$var2\ -text\ \$::SUMS(\$var2)\n\}\nproc\ bbox\ \{x\ y\ r\}\ \{\n\ \ \ \ return\ \[list\ \[expr\ \{\$x-\$r\}\]\ \[expr\ \{\$y-\$r\}\]\ \[expr\ \{\$x+\$r\}\]\ \[expr\ \{\$y+\$r\}\]\]\n\}\nproc\ ReCenter\ \{W\ h\ w\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Called\ by\ configure\ event\n\ \ \ \ Clear\n\ \ \ \ \$W\ config\ -scrollregion\ \[list\ \[expr\ \{-\$w/2\}\]\ 0\ \[expr\ \{\$w/2\}\]\ \$h\]\n\ \ \ \ DrawRamps\n\ \ \ \ DrawSums\n\}\nproc\ MoveAbs\ \{id\ xy\}\ \{\n\ \ \ \ lassign\ \$::B(\$id,xy)\ x0\ y0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Where\ it\ is\ now\n\ \ \ \ lassign\ \$xy\ x\ y\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Where\ to\ put\ it\n\ \ \ \ .c\ move\ \$id\ \[expr\ \{\$x\ -\ \$x0\}\]\ \[expr\ \{\$y\ -\ \$y0\}\]\n\ \ \ \ set\ ::B(\$id,xy)\ \$xy\n\}\nproc\ Ball2Canvas\ \{id\}\ \{\n\ \ \ \ global\ PEG\ B\ S\n\n\ \ \ \ set\ step\ \$B(\$id,step)\n\ \ \ \ if\ \{\$B(\$id,where)\ ==\ \"ramp\"\}\ \{\n\ \ \ \ \ \ \ \ lassign\ \$S(entry,\$B(\$id,peg))\ x\ y\n\ \ \ \ \ \ \ \ set\ dx\ \[expr\ \{\$step\ *\ (\$S(drop,x)\ -\ \$x)\ /\ \$S(rsteps)\}\]\n\ \ \ \ \ \ \ \ set\ dy\ \[expr\ \{\$step\ *\ (\$S(drop,y)\ -\ \$y)\ /\ \$S(rsteps)\}\]\n\ \ \ \ \ \ \ \ set\ x\ \[expr\ \{\$x\ +\ \$dx\}\]\n\ \ \ \ \ \ \ \ set\ y\ \[expr\ \{\$y\ +\ \$dy\}\]\n\ \ \ \ \ \ \ \ return\ \[list\ \$x\ \$y\]\n\ \ \ \ \}\n\ \ \ \ if\ \{\$B(\$id,where)\ ==\ \"drop\"\}\ \{\n\ \ \ \ \ \ \ \ lassign\ \$PEG(\$B(\$id,peg))\ x\ y\ \ \ \ \ \ \ \ \;#\ Where\ we\ land\n\ \ \ \ \ \ \ \ set\ dy\ \[expr\ \{\$step\ *\ (\$y\ -\ \$S(drop,y))\ /\ \$S(dsteps)\}\]\n\ \ \ \ \ \ \ \ set\ y\ \[expr\ \{\$S(drop,y)\ +\ \$dy\}\]\n\ \ \ \ \ \ \ \ return\ \[list\ \$x\ \$y\]\n\ \ \ \ \}\n\ \ \ \ if\ \{\$B(\$id,where)\ ==\ \"hold\"\}\ \{\ \ \ \ \ \ \ \ \;#\ Hold\ still\n\ \ \ \ \ \ \ \ lassign\ \$PEG(\$B(\$id,peg))\ x\ y\ \ \ \ \ \ \ \ \;#\ Where\ we\ land\n\ \ \ \ \ \ \ \ return\ \[list\ \$x\ \$S(bh)\]\n\ \ \ \ \ \ \ \ return\ \[list\ \$x\ \$S(drop,y)\]\n\ \ \ \ \}\n\ \ \ \ lassign\ \$PEG(\$B(\$id,peg))\ x\ y\ \ \ \ \ \ \ \ \;#\ Last\ peg\ hit\n\ \ \ \ set\ dx\ \[expr\ \{\$step\ *\ \$S(xspacing)\ /\ double(\$S(psteps))\}\]\n\ \ \ \ set\ xx\ \[expr\ \{\$x\ +\ \$B(\$id,dir)\ *\ \$dx\}\]\n\n\ \ \ \ set\ upsteps\ 2\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ How\ many\ steps\ going\ up\n\ \ \ \ set\ updist\ -10\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ How\ far\ up\ to\ go\n\n\ \ \ \ if\ \{\$step\ ==\ 0\}\ \{\n\ \ \ \ \ \ \ \ set\ dy\ 0\n\ \ \ \ \}\ elseif\ \{\$step\ <=\ \$upsteps\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Bounce\ up\ a\ bit\n\ \ \ \ \ \ \ \ set\ dy\ \[expr\ \{\$step\ *\ \$updist\ /\ double(\$upsteps)\}\]\n\ \ \ \ \}\ elseif\ \{\$step\ >\ \$upsteps\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Going\ down\ now\n\ \ \ \ \ \ \ \ set\ dist\ \[expr\ \{\$S(yspacing)\ -\ \$updist\}\]\;#\ How\ far\ to\ go\n\ \ \ \ \ \ \ \ set\ tsteps\ \[expr\ \{\$S(psteps)\ -\ \$upsteps\}\]\ \;#\ How\ many\ steps\ to\ do\ it\ in\n\ \ \ \ \ \ \ \ incr\ step\ \[expr\ \{-\$upsteps\}\]\n\ \ \ \ \ \ \ \ set\ dy\ \[expr\ \{\$updist\ +\ \$step\ *\ \$dist\ /\ double(\$tsteps)\}\]\n\ \ \ \ \}\n\ \ \ \ set\ yy\ \[expr\ \{\$y\ +\ \$dy\}\]\n\n\ \ \ \ return\ \[list\ \$xx\ \$yy\]\n\}\nproc\ CreateBall\ \{\}\ \{\n\ \ \ \ global\ B\ S\n\n\ \ \ \ set\ id\ \"B\[incr\ S(bnum)\]\"\n\ \ \ \ set\ B(\$id,where)\ ramp\n\ \ \ \ set\ B(\$id,peg)\ \[expr\ \{rand()\ >\ .5\ ?\ 0\ :\ 1\}\]\ \;#\ Which\ side\ to\ launch\ from\n\ \ \ \ set\ B(\$id,step)\ -1\n\ \ \ \ set\ B(\$id,dir)\ \[expr\ \{rand()\ <\ (\$S(bias)\ +\ 10)/20.0\ ?\ 1\ :\ -1\}\]\n\ \ \ \ set\ B(\$id,xy)\ \{-9999\ -9999\}\n\ \ \ \ set\ num\ \[expr\ \{int(rand()\ *\ 3)\}\]\n\ \ \ \ .c\ create\ image\ \$B(\$id,xy)\ -anchor\ s\ \\\n\ \ \ \ \ \ \ \ -image\ ::img::ball(\$num)\ -tag\ \[list\ ball\ \$id\]\n\n\ \ \ \ if\ \{!\ \$S(ramp)\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ No\ ramp\ mode\n\ \ \ \ \ \ \ \ set\ col\ \[expr\ \{2*int(\$S(cols)\ *\ (rand()\ -\ .5))\}\]\n\ \ \ \ \ \ \ \ set\ B(\$id,peg)\ \"\$col,0\"\n\ \ \ \ \ \ \ \ set\ B(\$id,where)\ \"hold\"\n\ \ \ \ \}\n\n\ \ \ \ MoveOneBall\ \$id\n\ \ \ \ return\ \$id\n\}\nproc\ MoveBall\ \{id\}\ \{\n\ \ \ \ global\ B\ S\ SUMS\n\n\ \ \ \ incr\ B(\$id,step)\n\ \ \ \ if\ \{\$B(\$id,where)\ ==\ \"ramp\"\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\$B(\$id,step)\ >=\ \$S(rsteps)\}\ \{\ \ \ \ \ \ \ \ \;#\ Done\ with\ the\ ramp\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,step)\ 0\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,where)\ \"drop\"\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,peg)\ \"0,0\"\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Peg\ to\ drop\ to\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ elseif\ \{\$B(\$id,where)\ ==\ \"drop\"\}\ \{\ \ \ \ \ \ \ \ \;#\ Dropping\ through\ the\ hole\n\ \ \ \ \ \ \ \ if\ \{\$B(\$id,step)\ >=\ \$S(dsteps)\}\ \{\ \ \ \ \ \ \ \ \;#\ Done\ with\ the\ drop\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$S(sound)\}\ \{snd_click\ play\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,step)\ 0\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,where)\ \"peg\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ elseif\ \{\$B(\$id,where)\ ==\ \"hold\"\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\$B(\$id,step)\ >=\ \$S(hsteps)\}\ \{\ \ \ \ \ \ \ \ \;#\ Done\ holding,\ let\ her\ drop\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,step)\ 0\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,where)\ \"drop\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ elseif\ \{\$B(\$id,where)\ ==\ \"peg\"\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\$B(\$id,step)\ >=\ \$S(psteps)\}\ \{\ \ \ \ \ \ \ \ \;#\ Hit\ the\ next\ peg\n\ \ \ \ \ \ \ \ \ \ \ \ lassign\ \[split\ \$B(\$id,peg)\ \",\"\]\ col\ row\n\ \ \ \ \ \ \ \ \ \ \ \ incr\ col\ \$B(\$id,dir)\n\ \ \ \ \ \ \ \ \ \ \ \ incr\ row\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$row\ >=\ \$S(rows)\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Off\ the\ bottom\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$SUMS(\$col)\ ==\ \"\"\}\ \{set\ SUMS(\$col)\ 0\}\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ incr\ SUMS(\$col)\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ array\ unset\ B\ \$id,*\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ .c\ delete\ \$id\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$S(sound)\}\ \{snd_click\ play\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,peg)\ \"\$col,\$row\"\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,dir)\ \[expr\ \{rand()\ <\ (\$S(bias)\ +\ 10)/20.0\ ?\ 1\ :\ -1\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,step)\ 0\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ set\ xy\ \[Ball2Canvas\ \$id\]\n\ \ \ \ MoveAbs\ \$id\ \$xy\n\}\nproc\ MoveOneBall\ \{id\ \{single\ 0\}\}\ \{\n\ \ \ \ global\ B\ S\n\n\ \ \ \ set\ ttime\ \[clock\ clicks\ -milliseconds\]\n\ \ \ \ if\ \{!\ \[info\ exists\ B(\$id,peg)\]\}\ return\n\ \ \ \ if\ \{\$S(stop)\ &&\ !\ \$single\}\ return\n\ \ \ \ MoveBall\ \$id\n\ \ \ \ if\ \{\$single\}\ return\n\ \ \ \ set\ ttime\ \[expr\ \{\[clock\ clicks\ -milliseconds\]\ -\ \$ttime\}\]\n\ \ \ \ set\ delay\ \[expr\ \{110\ -\ 10*\$S(speed)\}\]\n\ \ \ \ set\ delay\ \[expr\ \{\$ttime\ >\ \$delay\ ?\ 0\ :\ \$delay\ -\ \$ttime\}\]\n\ \ \ \ after\ \$delay\ \[list\ MoveOneBall\ \$id\]\n\}\nproc\ Go\ \{\}\ \{\n\ \ \ \ global\ B\ S\n\n\ \ \ \ if\ \{\$S(stop)\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ We're\ stopped\n\ \ \ \ \ \ \ \ .go\ config\ -text\ \"Stop\"\n\ \ \ \ \ \ \ \ set\ S(stop)\ 0\n\ \ \ \ \ \ \ \ foreach\ ball\ \[array\ names\ B\ *,xy\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ id\ \[lindex\ \[split\ \$ball\ \",\"\]\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ after\ \[expr\ \{110\ -\ 10*\$S(speed)\}\]\ \[list\ MoveOneBall\ \$id\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ Birth\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ foreach\ a\ \[after\ info\]\ \{after\ cancel\ \$a\}\n\ \ \ \ \ \ \ \ .go\ config\ -text\ \"Go\"\n\ \ \ \ \ \ \ \ set\ S(stop)\ 1\n\ \ \ \ \}\n\}\nproc\ Clear\ \{\}\ \{\n\ \ \ \ set\ stop\ \$::S(stop)\n\ \ \ \ if\ \{!\ \$stop\}\ Go\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Stop\ everything\n\ \ \ \ foreach\ a\ \[array\ names\ ::SUMS\]\ \{\ set\ ::SUMS(\$a)\ \"\"\ \}\n\ \ \ \ foreach\ a\ \[array\ names\ ::B\]\ \{\ unset\ ::B(\$a)\ \}\n\ \ \ \ .c\ delete\ ball\n\ \ \ \ if\ \{!\ \$stop\}\ Go\n\}\nproc\ Birth\ \{\}\ \{\n\ \ \ \ global\ S\n\n\ \ \ \ if\ \{\$S(stop)\ ||\ !\ \$S(auto)\}\ return\n\ \ \ \ CreateBall\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Called\ for\ a\ new\ birth\n\ \ \ \ NewBirth\ \$S(birth)\n\}\nproc\ NewBirth\ \{val\}\ \{\n\ \ \ \ global\ S\n\n\ \ \ \ after\ cancel\ Birth\n\ \ \ \ set\ rate\ \[expr\ \{103\ -\ \$S(birth)\}\]\n\ \ \ \ set\ delay\ \[expr\ \{110\ -\ 10*\$S(speed)\}\]\n\ \ \ \ set\ delay\ \[expr\ \{\$delay\ *\ \$rate\ +\ round(200\ *\ rand())\}\]\n\ \ \ \ after\ \$delay\ Birth\n\}\nproc\ DoSounds\ \{\}\ \{\n\ \ \ \ proc\ snd_click\ \{play\}\ \{\}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Stub\n\ \ \ \ if\ \{\[catch\ \{package\ require\ base64\}\]\}\ return\n\ \ \ \ if\ \{\[catch\ \{package\ require\ snack\}\]\}\ return\n\ \ \ \ set\ sdata\ \{UklGRkACAABXQVZFZm10IBAAAAABAAEAESsAABErAAABAAgAZGF0YRwCAACAgId0Z\n\ \ \ \ \ \ \ \ HZbU5aMj7/MsIZ6UX6nWIiITWiIRUGUlZesvrGCiKiKTl96Fit3YF5emrGHqcqhlJuAdWxgW\n\ \ \ \ \ \ \ \ 01EbWSHubW1uJ2MkqGPYFVSamtvgHmEh5ybraWLkHp5Xm5oWGRvb3WSlYqMi4+JhY6Ac25xd\n\ \ \ \ \ \ \ \ Xp5jYR/hoODdIN8e356goCHgoqGgIV/g35/d3N2eHZ6gIOIgouHioaNioGAfHpycHp2dH2Hi\n\ \ \ \ \ \ \ \ ouNiYiKhIF9enZzd3l+dX2BgYKIjoaJhIJ/fX6AfHl8fICAgICEgISFhYF/gH+AfIJ/gH6Af\n\ \ \ \ \ \ \ \ X6AfICAfYB+gn2DfoGAgIOAgYB8e3x9gIKChYCDgIN/g32Afn+BgIF+gH+BgIOAgX2CfYGAg\n\ \ \ \ \ \ \ \ IB/gH9/fIB/gICBgH+Df4KAgIB9gHuBfYKAgoCAhICDgIN+gH+Af4CAgIGAg4CFgIOAgICAg\n\ \ \ \ \ \ \ \ H9/f32AfoF/gn+BgICAf4B/gICAgICAgIKAgYCAgH+AfYB8f4CAgoGBgIKBgHt0cnqEi4yIh\n\ \ \ \ \ \ \ \ oKHioOBeoF+gHRvbW10eYSHhoyMmI+PhIF5dm9tbW92fICJjpKRkY6JhHx5b2xlbnWAhYeOj\n\ \ \ \ \ \ \ \ pSQkIiAe3R1cnNzdnx/gomLj4yJhICAfHp3d3d6fYKDhoKGgIeAhX1/eXt9foCAg4GCg4CDf\n\ \ \ \ \ \ \ \ YF6gHmAfYCBgIR/h4CEf4B9fn98gHuEfYV/g4CAgn6Fe4R6gn1/gHuDe4V+g4CAgn8=\}\n\ \ \ \ regsub\ -all\ \{\\s\}\ \$sdata\ \{\}\ sdata\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Bug\ in\ base64\ package\n\ \ \ \ sound\ snd_click\n\ \ \ \ snd_click\ data\ \[::base64::decode\ \$sdata\]\n\ \ \ \ .sound\ config\ -state\ normal\n\}\n\nDoDisplay\n----\n\[GN\]\ 2004-07-30\ :\ wow\ -\ Uses\ 80%\ +\ of\ my\ dual\ 2.0G5s\ cpu\ in\ max\ speed\n\n<<categories>>\ Graphics\ |\ Application\ |\ Whizzlet\ |\ Animation regexp2} CALL {my render {Falling Marbles} \[Keith\ Vetter\]\ 2003-04-29\ :\ here's\ fun\ little\ animation\ of\ marbles\ cascading\ndown\ a\ peg\ board.\ The\ images\ for\ the\ marbles\ come\ from\ \[gifBalls\].\n\n\[http://www.tcl.tk/starkits/marbles.jpg\]\n\n\[KPV\]\ 2003-04-30\ :\ put\ up\ a\ new\ version\ with\ better\ resizing\ behavior,\ sound\nand\ more\ controls.\n\n\[KPV\]\ 2003-05-02\ :\ added\ no\ ramp\ mode\n\n----\n\n\[TV\]\ Good\ visual\ effect.\ Makes\ me\ wonder\ about\ scaling,\ both\ the\ graphics,\ and\ the\ machine\ horsepower\ versus\ update\ rate\ or\ bounce\ increment.\ And\ colliding\ balls.\n\n\[KPV\]\ Thanks.\ As\ to\ scaling\ issues,\ let's\ first\ take\ horsepower.\ \n\[Creating\ an\ animated\ display\]\ discusses\ this\ issue--basically\neach\ frame\ has\ an\ allotted\ amount\ of\ time\ to\ complete\ and,\ by\ using\ the\ \[after\]\ \ncommand,\ the\ next\ frame\ is\ not\ drawn\ until\ that\ time\ has\ elapsed.\ So\ a\ slow\nmachine\ will\ consume\ more\ of\ each\ time\ allotment\ while\ fast\ machines\ will\ \nconsume\ less,\ but,\ theoretically,\ they\ both\ should\ produce\ the\ same\ display.\n\nThe\ way\ to\ handle\ graphic\ scaling\ is\ to\ use\ Newtonian\ physics\ with\ gravity\nacceleration\ and\ velocity\ to\ compute\ a\ ball's\ path\ through\ the\ pegs.\ This\nisn't\ that\ hard,\ but\ since\ my\ ball\ GIF\ images\ don't\ scale\ nicely,\ I\ just\ \nfaked\ it--2\ steps\ up\ and\ 5\ steps\ down.\n----\n\[escargo\]\ -\ I\ was\ noticing\ that\ the\ \"Birth\ Rate\"\ was\ not\ acting\ the\ way\ I\ was\ expecting.\nLooking\ at\ the\ code\ I\ noticed\ the\ following\ things\ in\ the\ NewBirth\ proc.\n\n\ \ \ *\ The\ ''val''\ parameter\ is\ not\ used.\n\ \ \ *\ The\ ''rate''\ variable\ is\ inverted\ relative\ to\ the\ scale\ widget\ value\ (which\ means\ at\ the\ very\ least\ that\ it\ has\ the\ wrong\ name).\n\ \ \ *\ The\ greater\ the\ speed\ setting,\ the\ lower\ the\ delay\ (which\ is\ good).\n\nMy\ user\ expectation\ is\ that\ changing\ the\ \"Birth\ Rate\"\ should\ result\ in\ something\ like\nlinear\ changes\ in\ the\ birth\ rate.\ \ That's\ not\ what\ I\ observe.\ \ Am\ I\ missing\ something?\n\n\[KPV\]\ -\ My\ intent\ was\ that\ birth\ rate\ is\ births\ per\ unit\ time\ meaning\nthat\ a\ larger\ value\ results\ in\ more\ balls\ coming\ out.\ That\ is\ why\ the\nscale\ value\ gets\ inverted.\ The\ result\ should\ be\ linear--doubling\ the\ \nvalue\ means\ that\ twice\ as\ many\ balls\ coming\ out--but\ I\ do\ add\ in\ a\ random\ndelay\ that\ may\ skew\ your\ perception.\n\nThe\ reason\ why\ the\ ''val''\ parameter\ isn't\ used\ by\ NewBirth\nis\ partly\ historical\ and\ partly\ a\ lost\ feature\ (oops).\ Originally\ NewBirth\ntook\ no\ parameter\ but\ then\ I\ thought\ it\ would\ be\ nice\ if\ changing\nthe\ birth\ rate\ took\ effect\ immediately.\ So\ I\ set\ the\ scale's\ command\ to\ be\nNewBirth\ but\ that\ meant\ that\ NewBirth\ had\ to\ take\ a\ parameter.\ That\ new\ parameter\nchange\ got\ in\ the\ final\ version\ but\ somehow\ the\ added\ command\ to\ the\ scale\nwidget\ got\ lost\ (I've\ now\ added\ it\ in).\n\n\[escargo\]\ Even\ the\ new\ version\ seems\ like\ a\ very\ nonlinear\ frequency\ change\ between\ndifferent\ \"Birth\ Rate\"\ values.\ \ (Pehaps\ the\ only\ way\ to\ find\ out\ would\ be\ to\ add\na\ field\ that\ showed\ internal\ values.\ \ I\ don't\ know\ if\ the\ problem\ is\ perceptual\n(rate\ really\ is\ linear)\ or\ procedural\ (rate\ really\ isn't\ linear).\n\n----\n======\n##+##########################################################################\n#\n#\ Falling\ Marbles\n#\ by\ Keith\ Vetter,\ April\ 2003\n#\ KPV\ Apr\ 30,\ 2003\ -\ better\ resizing\ behavior,\ sound,\ more\ controls\n#\ KPV\ May\ \ 2,\ 2003\ -\ added\ no\ ramp\ mode\n#\n\npackage\ require\ Tk\n\narray\ set\ S\ \{title\ \"Falling\ Marbles\"\ top\ 70\ bottom\ 20\ xspacing\ 20\ yspacing\ 30\n\ \ \ \ pegsize\ 3\ bnum\ 0\ stop\ 1\ bias\ 0\ speed\ 5\ sound\ 0\ auto\ 1\ birth\ 96\ ramp\ 1\}\n\nset\ S(psteps)\ 7\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Steps\ falling\ between\ pegs\nset\ S(rsteps)\ 15\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Steps\ rolling\ down\ ramp\nset\ S(dsteps)\ 3\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Steps\ dropping\ to\ first\ peg\nset\ S(hsteps)\ 10\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Steps\ holding\ still\n\nproc\ DoDisplay\ \{\}\ \{\n\ \ \ \ global\ S\n\n\ \ \ \ #\ see\ http://wiki.tcl.tk/gifBalls\n\ \ \ \ set\ ball(red)\ \{R0lGODlhFAAPAPMPAAAAADgFD00CEGoDGHMTJ21ZXZISK6USL7MoRJ1aZ\n\ \ \ \ \ \ \ \ 9IzUvRUdNVAXscbPv9ylKqcniH5BAEAAAAALAAAAAAUAA8AAARwEMgpX7qPavrQ+YdBZ\n\ \ \ \ \ \ \ \ Nv0HIDCKE04kNvZMEvNeIMAU8mhLI7gQuEqlAwHWtCxYLgIMeRvOTwQBoHS4ICg2RCGX\n\ \ \ \ \ \ \ \ HZDQCIUaPBVMNYkBgZkSCQ2lgSDAWGfZwd2HAJ4fX6AGg9sggGLhiUPBZCNJZMaEQA7\}\n\ \ \ \ set\ ball(yellow)\ \{R0lGODlhFAAPAPMPAAAAADExBD09Kk5OAmtrDFNTKmxsWImJFLCwM5\n\ \ \ \ \ \ \ \ mZJaCgUsXFONPTUvb2ceXlWKennCH5BAEAAAAALAAAAAAUAA8AAARqEMgpX1Lq0U3t+Q\n\ \ \ \ \ \ \ \ dBaNz0HAmyIEk4kNyZLI7DMC3xlsqBOI0gA+EylAgpoJCoK8QIPkbQxhwEjqjFbZgQWY\n\ \ \ \ \ \ \ \ /QFILlClw5hoEI5LUaSwO1SBc3wzaPgCC+NwfuMX5+AoAlAA8GBQaFho0UEQA7\}\n\ \ \ \ set\ ball(green)\ \{R0lGODlhFAAPAPQAAAAAAAA4BwBNCgBqEgBzE0ZtTACSEwClFgqzJj+d\n\ \ \ \ \ \ \ \ TADHIQ/SKRzVOyv0RUf/bH+qgwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n\ \ \ \ \ \ \ \ AAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAUAA8AAAV2ICSO4pOcD6mSD3K8h0Gk6/\n\ \ \ \ \ \ \ \ gc0MIsSjzQq5uC0SgyXAMBkJQ4LBqOaGPhK9QMB2LU0WD4CEHsczs9EAaB2uCAIBoRhmR\n\ \ \ \ \ \ \ \ 6RcAiFnj4WTBXJQYGWDEyclY1AgMDBIuJfAFLLAKIjY6QKg98kgGbljUPBaCdNaMqIQA7\}\n\n\ \ \ \ wm\ title\ .\ \$S(title)\n\ \ \ \ pack\ \[frame\ .ctrl\ -relief\ ridge\ -bd\ 2\ -padx\ 5\ -pady\ 5\]\ \\\n\ \ \ \ \ \ \ \ -side\ right\ -fill\ both\ -ipady\ 5\n\ \ \ \ pack\ \[frame\ .screen\ -bd\ 2\ -relief\ raised\]\ -side\ left\ -fill\ both\ -expand\ 1\n\n\ \ \ \ canvas\ .c\ -borderwidth\ 0\ -height\ 500\ -width\ 600\ \\\n\ \ \ \ \ \ \ \ -highlightthickness\ 0\ -scrollregion\ \{-300\ 0\ 300\ 500\}\n\n\ \ \ \ bind\ all\ <Alt-c>\ \{console\ show\}\n\n\ \ \ \ DoCtrlFrame\n\ \ \ \ foreach\ b\ \{red\ yellow\ green\}\ num\ \{0\ 1\ 2\}\ \{\n\ \ \ \ \ \ \ \ image\ create\ photo\ ::img::ball(\$num)\ -data\ \$ball(\$b)\n\ \ \ \ \}\n\n\ \ \ \ set\ S(bw)\ \[image\ width\ ::img::ball(0)\]\n\ \ \ \ set\ S(bh)\ \[image\ height\ ::img::ball(0)\]\n\n\ \ \ \ bind\ .c\ <Configure>\ \{\n\ \ \ \ \ \ \ \ DrawPegs\n\ \ \ \ \ \ \ \ DrawSums\n\ \ \ \ \ \ \ \ DrawRamps\n\ \ \ \ \ \ \ \ DoSounds\n\ \ \ \ \ \ \ \ ReCenter\ %W\ %h\ %w\n\ \ \ \ \ \ \ \ Go\n\ \ \ \ \}\n\ \ \ \ pack\ .c\ -in\ .screen\ -side\ left\ -fill\ both\ -expand\ 1\n\}\nproc\ DoCtrlFrame\ \{\}\ \{\n\ \ \ \ button\ .go\ -text\ \"Go\"\ -command\ Go\ -bd\ 4\n\ \ \ \ .go\ configure\ -font\ \"\[font\ actual\ \[.go\ cget\ -font\]\]\ -weight\ bold\"\n\ \ \ \ button\ .clear\ -text\ \"Clear\"\ -command\ Clear\ -bd\ 4\ -font\ \[.go\ cget\ -font\]\n\ \ \ \ button\ .new\ -text\ \"New\ Ball\"\ -command\ CreateBall\ -bd\ 4\ -font\ \[.go\ cget\ -font\]\n\ \ \ \ checkbutton\ .sound\ -text\ \"Sound\"\ -relief\ raised\ -bd\ 4\ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ -variable\ S(sound)\ -padx\ 10\ -anchor\ w\ -font\ \[.go\ cget\ -font\]\n\ \ \ \ checkbutton\ .auto\ -text\ \"Auto\ Ball\"\ -relief\ raised\ -bd\ 4\ -command\ Birth\ \\\n\ \ \ \ \ \ \ \ -variable\ S(auto)\ -padx\ 10\ -anchor\ w\ -font\ \[.go\ cget\ -font\]\n\ \ \ \ checkbutton\ .ramp\ -text\ \"Ramp\"\ -relief\ raised\ -bd\ 4\ -command\ DrawRamps\ \\\n\ \ \ \ \ \ \ \ -variable\ S(ramp)\ -padx\ 10\ -anchor\ w\ -font\ \[.go\ cget\ -font\]\n\n\ \ \ \ button\ .about\ -text\ \"About\"\ -font\ \[.go\ cget\ -font\]\ -command\ \\\n\ \ \ \ \ \ \ \ \[list\ tk_messageBox\ -message\ \"\$::S(title)\\nby\ Keith\ Vetter,\ April\ 2003\"\]\n\ \ \ \ scale\ .speed\ -orient\ h\ -from\ 1\ -to\ 10\ -font\ \[.go\ cget\ -font\]\ \\\n\ \ \ \ \ \ \ \ -variable\ S(speed)\ -bd\ 2\ -relief\ ridge\ -showvalue\ 1\ -label\ Speed\n\ \ \ \ scale\ .birth\ -orient\ h\ -from\ 3\ -to\ 100\ -font\ \[.go\ cget\ -font\]\ \\\n\ \ \ \ \ \ \ \ -variable\ S(birth)\ -bd\ 2\ -relief\ ridge\ -showvalue\ 1\ -label\ \"Birth\ Rate\"\ \\\n\ \ \ \ \ \ \ \ -command\ NewBirth\n\ \ \ \ scale\ .bias\ -orient\ h\ -from\ -10\ -to\ 10\ -font\ \[.go\ cget\ -font\]\ \\\n\ \ \ \ \ \ \ \ -variable\ S(bias)\ -bd\ 2\ -relief\ ridge\ -showvalue\ 1\ -label\ \"Bias\"\n\n\ \ \ \ grid\ .go\ -in\ .ctrl\ -sticky\ ew\ -row\ 0\n\ \ \ \ grid\ .clear\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ .new\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ rowconfigure\ .ctrl\ 10\ -minsize\ 10\n\ \ \ \ grid\ .sound\ -in\ .ctrl\ -sticky\ ew\ -row\ 11\n\ \ \ \ grid\ .auto\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ .ramp\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ rowconfigure\ .ctrl\ 30\ -minsize\ 20\n\ \ \ \ grid\ .speed\ -in\ .ctrl\ -sticky\ ew\ -row\ 31\n\ \ \ \ grid\ .birth\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ .bias\ -in\ .ctrl\ -sticky\ ew\n\ \ \ \ grid\ rowconfigure\ .ctrl\ 50\ -weight\ 1\n\ \ \ \ grid\ .about\ -in\ .ctrl\ -sticky\ ew\ -row\ 100\n\}\nproc\ DrawPegs\ \{\}\ \{\n\ \ \ \ global\ S\ PEG\ SUMS\n\n\ \ \ \ .c\ delete\ peg\n\ \ \ \ lassign\ \[.c\ cget\ -scrollregion\]\ X0\ Y0\ X1\ Y1\n\n\ \ \ \ set\ top\ \[expr\ \{\$Y0\ +\ \$S(top)\}\]\n\ \ \ \ set\ bottom\ \[expr\ \{\$Y1\ -\ \$S(bottom)\}\]\n\ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ 50\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ \ \ set\ y\ \[expr\ \{\$top\ +\ \$row\ *\ \$S(yspacing)\}\]\n\ \ \ \ \ \ \ \ #if\ \{\$y\ >\ \$bottom\}\ break\n\n\ \ \ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ 50\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ x\ \[expr\ \{\$col\ *\ \$S(xspacing)\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ set\ PEG(\$col,\$row)\ \[list\ \$x\ \$y\]\n\ \ \ \ \ \ \ \ \ \ \ \ set\ PEG(-\$col,\$row)\ \[list\ -\$x\ \$y\]\n\ \ \ \ \ \ \ \ \ \ \ \ #if\ \{\$x\ >\ \$X1\}\ continue\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{(\$row\ &\ 1)\ &&\ !(\$col\ &\ 1)\}\ continue\ \;#\ Odd\ row,\ even\ column\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{!(\$row\ &\ 1)\ &&\ (\$col\ &\ 1)\}\ continue\ \;#\ Even\ row,\ odd\ column\n\n\ \ \ \ \ \ \ \ \ \ \ \ .c\ create\ oval\ \[bbox\ \$x\ \$y\ \$S(pegsize)\]\ -tag\ peg\ -fill\ black\n\ \ \ \ \ \ \ \ \ \ \ \ .c\ create\ oval\ \[bbox\ -\$x\ \$y\ \$S(pegsize)\]\ -tag\ peg\ -fill\ black\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\n\ \ \ \ .c\ create\ rect\ 0\ 0\ 0\ 0\ -tag\ sum\ -fill\ \[.c\ cget\ -bg\]\ -outline\ \{\}\n\ \ \ \ #\ Sums\ text\n\ \ \ \ set\ y\ \[expr\ \{\$Y1\ -\ 2\}\]\n\ \ \ \ set\ font\ \{\{Times\ Roman\}\ 8\ bold\}\n\ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ 50\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ set\ x\ \[expr\ \{\$col\ *\ \$S(xspacing)\}\]\n\ \ \ \ \ \ \ \ .c\ create\ text\ \$x\ \$y\ -tag\ e\$col\ -font\ \$font\ -anchor\ s\n\ \ \ \ \ \ \ \ .c\ create\ text\ -\$x\ \$y\ -tag\ e-\$col\ -font\ \$font\ -anchor\ s\n\ \ \ \ \ \ \ \ set\ SUMS(\$col)\ \[set\ SUMS(-\$col)\ \"\"\]\n\ \ \ \ \}\n\ \ \ \ trace\ variable\ SUMS\ w\ TraceSums\n\}\nproc\ DrawSums\ \{\}\ \{\n\ \ \ \ global\ S\ PEG\n\n\ \ \ \ lassign\ \[.c\ cget\ -scrollregion\]\ X0\ Y0\ X1\ Y1\n\ \ \ \ set\ bottom\ \[expr\ \{\$Y1\ -\ \$S(bottom)\}\]\n\n\ \ \ \ for\ \{set\ row\ 0\}\ \{1\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ \ \ lassign\ \$PEG(0,\$row)\ x\ y\n\ \ \ \ \ \ \ \ if\ \{\$y\ >\ \$bottom\}\ break\n\ \ \ \ \}\n\ \ \ \ set\ S(rows)\ \$row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Number\ of\ visible\ rows\n\ \ \ \ set\ S(cols)\ \[expr\ \{int(double(\$X1)\ /\ \$S(xspacing))\ |\ 1\}\]\n\ \ \ \ .c\ coords\ sum\ -999\ \[expr\ \{\$y\ -\ \$S(pegsize)\}\]\ 999\ \$Y1\ \;#\ Blank\ out\ bottom\n\n\ \ \ \ #\ Reposition\ counters\n\ \ \ \ set\ y\ \[expr\ \{\$Y1\ -\ 2\}\]\n\ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ 50\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ set\ x\ \[expr\ \{\$col\ *\ \$S(xspacing)\}\]\n\ \ \ \ \ \ \ \ .c\ coords\ e\$col\ \$x\ \$y\n\ \ \ \ \ \ \ \ .c\ coords\ e-\$col\ -\$x\ \$y\n\ \ \ \ \}\n\}\nproc\ DrawRamps\ \{\}\ \{\n\ \ \ \ global\ S\ B\n\n\ \ \ \ .c\ delete\ ramp\ door\n\ \ \ \ foreach\ a\ \[array\ names\ B\ *,where\]\ \{\n\ \ \ \ \ \ \ \ if\ \{\$B(\$a)\ ==\ \"ramp\"\ ||\ \$B(\$a)\ ==\ \"hold\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ id\ \[lindex\ \[split\ \$a\ \",\"\]\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ array\ unset\ B\ \$id,*\n\ \ \ \ \ \ \ \ \ \ \ \ .c\ delete\ \$id\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ if\ \{!\ \$S(ramp)\}\ return\n\n\ \ \ \ lassign\ \[.c\ cget\ -scrollregion\]\ X0\ Y0\ X1\ Y1\n\ \ \ \ set\ x0\ \$X1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y0\ \[expr\ \{\$Y0\ +\ \$S(bh)\}\]\n\ \ \ \ set\ x1\ \[expr\ \{\$S(bw)\ /\ 2\}\]\ \;\ set\ y1\ \[expr\ \{\$Y0\ +\ \$S(top)\ -\ 3*\$S(bh)\}\]\n\ \ \ \ set\ x2\ \$x1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y2\ \[expr\ \{\$y1\ +\ \$S(bh)\}\]\n\ \ \ \ set\ x3\ \$x0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y3\ \$y2\n\ \ \ \ set\ x4\ 5000\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y4\ \$y3\n\ \ \ \ set\ x5\ \$x4\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ set\ y5\ \$y0\n\ \ \ \ .c\ create\ poly\ \$x0\ \$y0\ \$x1\ \$y1\ \$x2\ \$y2\ \$x3\ \$y3\ \$x4\ \$y4\ \$x5\ \$y5\ -tag\ ramp\n\ \ \ \ .c\ create\ poly\ -\$x0\ \$y0\ -\$x1\ \$y1\ -\$x2\ \$y2\ -\$x3\ \$y3\ -\$x4\ \$y4\ -\$x5\ \$y5\ \\\n\ \ \ \ \ \ \ \ -tag\ ramp\n\n\ \ \ \ set\ S(rsteps)\ \[expr\ \{\$X1\ <\ 20\ ?\ 1\ :\ \$X1\ /\ 20\}\]\n\ \ \ \ set\ S(entry,0)\ \[list\ \[expr\ \{\$X0\ +\ \$S(bw)\ /\ 2.0\}\]\ \[expr\ \{\$Y0\ +\ \$S(bh)\ +\ 2\}\]\]\n\ \ \ \ set\ S(entry,1)\ \[list\ \[expr\ \{\$X1\ -\ \$S(bw)\ /\ 2.0\}\]\ \[expr\ \{\$Y0\ +\ \$S(bh)\ +\ 2\}\]\]\n\ \ \ \ set\ S(drop,x)\ 0\n\ \ \ \ set\ S(drop,y)\ \[expr\ \{\$y1\ +\ 3\}\]\n\n\ \ \ \ set\ x\ \[expr\ \{\$X1\ -\ \$S(bw)\}\]\ \;\ set\ y\ \[expr\ \{\$Y0\ +\ \$S(bh)\}\]\n\ \ \ \ .c\ create\ oval\ \$x\ \$Y0\ \$X1\ \$y\ -tag\ door\ -fill\ red\n\ \ \ \ .c\ create\ oval\ \[expr\ \{-1*\$x\}\]\ \$Y0\ \$X0\ \$y\ -tag\ door\ -fill\ red\n\}\nproc\ TraceSums\ \{var1\ var2\ op\}\ \{\n\ \ \ \ .c\ itemconfig\ e\$var2\ -text\ \$::SUMS(\$var2)\n\}\nproc\ bbox\ \{x\ y\ r\}\ \{\n\ \ \ \ return\ \[list\ \[expr\ \{\$x-\$r\}\]\ \[expr\ \{\$y-\$r\}\]\ \[expr\ \{\$x+\$r\}\]\ \[expr\ \{\$y+\$r\}\]\]\n\}\nproc\ ReCenter\ \{W\ h\ w\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Called\ by\ configure\ event\n\ \ \ \ Clear\n\ \ \ \ \$W\ config\ -scrollregion\ \[list\ \[expr\ \{-\$w/2\}\]\ 0\ \[expr\ \{\$w/2\}\]\ \$h\]\n\ \ \ \ DrawRamps\n\ \ \ \ DrawSums\n\}\nproc\ MoveAbs\ \{id\ xy\}\ \{\n\ \ \ \ lassign\ \$::B(\$id,xy)\ x0\ y0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Where\ it\ is\ now\n\ \ \ \ lassign\ \$xy\ x\ y\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Where\ to\ put\ it\n\ \ \ \ .c\ move\ \$id\ \[expr\ \{\$x\ -\ \$x0\}\]\ \[expr\ \{\$y\ -\ \$y0\}\]\n\ \ \ \ set\ ::B(\$id,xy)\ \$xy\n\}\nproc\ Ball2Canvas\ \{id\}\ \{\n\ \ \ \ global\ PEG\ B\ S\n\n\ \ \ \ set\ step\ \$B(\$id,step)\n\ \ \ \ if\ \{\$B(\$id,where)\ ==\ \"ramp\"\}\ \{\n\ \ \ \ \ \ \ \ lassign\ \$S(entry,\$B(\$id,peg))\ x\ y\n\ \ \ \ \ \ \ \ set\ dx\ \[expr\ \{\$step\ *\ (\$S(drop,x)\ -\ \$x)\ /\ \$S(rsteps)\}\]\n\ \ \ \ \ \ \ \ set\ dy\ \[expr\ \{\$step\ *\ (\$S(drop,y)\ -\ \$y)\ /\ \$S(rsteps)\}\]\n\ \ \ \ \ \ \ \ set\ x\ \[expr\ \{\$x\ +\ \$dx\}\]\n\ \ \ \ \ \ \ \ set\ y\ \[expr\ \{\$y\ +\ \$dy\}\]\n\ \ \ \ \ \ \ \ return\ \[list\ \$x\ \$y\]\n\ \ \ \ \}\n\ \ \ \ if\ \{\$B(\$id,where)\ ==\ \"drop\"\}\ \{\n\ \ \ \ \ \ \ \ lassign\ \$PEG(\$B(\$id,peg))\ x\ y\ \ \ \ \ \ \ \ \;#\ Where\ we\ land\n\ \ \ \ \ \ \ \ set\ dy\ \[expr\ \{\$step\ *\ (\$y\ -\ \$S(drop,y))\ /\ \$S(dsteps)\}\]\n\ \ \ \ \ \ \ \ set\ y\ \[expr\ \{\$S(drop,y)\ +\ \$dy\}\]\n\ \ \ \ \ \ \ \ return\ \[list\ \$x\ \$y\]\n\ \ \ \ \}\n\ \ \ \ if\ \{\$B(\$id,where)\ ==\ \"hold\"\}\ \{\ \ \ \ \ \ \ \ \;#\ Hold\ still\n\ \ \ \ \ \ \ \ lassign\ \$PEG(\$B(\$id,peg))\ x\ y\ \ \ \ \ \ \ \ \;#\ Where\ we\ land\n\ \ \ \ \ \ \ \ return\ \[list\ \$x\ \$S(bh)\]\n\ \ \ \ \ \ \ \ return\ \[list\ \$x\ \$S(drop,y)\]\n\ \ \ \ \}\n\ \ \ \ lassign\ \$PEG(\$B(\$id,peg))\ x\ y\ \ \ \ \ \ \ \ \;#\ Last\ peg\ hit\n\ \ \ \ set\ dx\ \[expr\ \{\$step\ *\ \$S(xspacing)\ /\ double(\$S(psteps))\}\]\n\ \ \ \ set\ xx\ \[expr\ \{\$x\ +\ \$B(\$id,dir)\ *\ \$dx\}\]\n\n\ \ \ \ set\ upsteps\ 2\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ How\ many\ steps\ going\ up\n\ \ \ \ set\ updist\ -10\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ How\ far\ up\ to\ go\n\n\ \ \ \ if\ \{\$step\ ==\ 0\}\ \{\n\ \ \ \ \ \ \ \ set\ dy\ 0\n\ \ \ \ \}\ elseif\ \{\$step\ <=\ \$upsteps\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Bounce\ up\ a\ bit\n\ \ \ \ \ \ \ \ set\ dy\ \[expr\ \{\$step\ *\ \$updist\ /\ double(\$upsteps)\}\]\n\ \ \ \ \}\ elseif\ \{\$step\ >\ \$upsteps\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Going\ down\ now\n\ \ \ \ \ \ \ \ set\ dist\ \[expr\ \{\$S(yspacing)\ -\ \$updist\}\]\;#\ How\ far\ to\ go\n\ \ \ \ \ \ \ \ set\ tsteps\ \[expr\ \{\$S(psteps)\ -\ \$upsteps\}\]\ \;#\ How\ many\ steps\ to\ do\ it\ in\n\ \ \ \ \ \ \ \ incr\ step\ \[expr\ \{-\$upsteps\}\]\n\ \ \ \ \ \ \ \ set\ dy\ \[expr\ \{\$updist\ +\ \$step\ *\ \$dist\ /\ double(\$tsteps)\}\]\n\ \ \ \ \}\n\ \ \ \ set\ yy\ \[expr\ \{\$y\ +\ \$dy\}\]\n\n\ \ \ \ return\ \[list\ \$xx\ \$yy\]\n\}\nproc\ CreateBall\ \{\}\ \{\n\ \ \ \ global\ B\ S\n\n\ \ \ \ set\ id\ \"B\[incr\ S(bnum)\]\"\n\ \ \ \ set\ B(\$id,where)\ ramp\n\ \ \ \ set\ B(\$id,peg)\ \[expr\ \{rand()\ >\ .5\ ?\ 0\ :\ 1\}\]\ \;#\ Which\ side\ to\ launch\ from\n\ \ \ \ set\ B(\$id,step)\ -1\n\ \ \ \ set\ B(\$id,dir)\ \[expr\ \{rand()\ <\ (\$S(bias)\ +\ 10)/20.0\ ?\ 1\ :\ -1\}\]\n\ \ \ \ set\ B(\$id,xy)\ \{-9999\ -9999\}\n\ \ \ \ set\ num\ \[expr\ \{int(rand()\ *\ 3)\}\]\n\ \ \ \ .c\ create\ image\ \$B(\$id,xy)\ -anchor\ s\ \\\n\ \ \ \ \ \ \ \ -image\ ::img::ball(\$num)\ -tag\ \[list\ ball\ \$id\]\n\n\ \ \ \ if\ \{!\ \$S(ramp)\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ No\ ramp\ mode\n\ \ \ \ \ \ \ \ set\ col\ \[expr\ \{2*int(\$S(cols)\ *\ (rand()\ -\ .5))\}\]\n\ \ \ \ \ \ \ \ set\ B(\$id,peg)\ \"\$col,0\"\n\ \ \ \ \ \ \ \ set\ B(\$id,where)\ \"hold\"\n\ \ \ \ \}\n\n\ \ \ \ MoveOneBall\ \$id\n\ \ \ \ return\ \$id\n\}\nproc\ MoveBall\ \{id\}\ \{\n\ \ \ \ global\ B\ S\ SUMS\n\n\ \ \ \ incr\ B(\$id,step)\n\ \ \ \ if\ \{\$B(\$id,where)\ ==\ \"ramp\"\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\$B(\$id,step)\ >=\ \$S(rsteps)\}\ \{\ \ \ \ \ \ \ \ \;#\ Done\ with\ the\ ramp\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,step)\ 0\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,where)\ \"drop\"\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,peg)\ \"0,0\"\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Peg\ to\ drop\ to\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ elseif\ \{\$B(\$id,where)\ ==\ \"drop\"\}\ \{\ \ \ \ \ \ \ \ \;#\ Dropping\ through\ the\ hole\n\ \ \ \ \ \ \ \ if\ \{\$B(\$id,step)\ >=\ \$S(dsteps)\}\ \{\ \ \ \ \ \ \ \ \;#\ Done\ with\ the\ drop\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$S(sound)\}\ \{snd_click\ play\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,step)\ 0\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,where)\ \"peg\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ elseif\ \{\$B(\$id,where)\ ==\ \"hold\"\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\$B(\$id,step)\ >=\ \$S(hsteps)\}\ \{\ \ \ \ \ \ \ \ \;#\ Done\ holding,\ let\ her\ drop\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,step)\ 0\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,where)\ \"drop\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ elseif\ \{\$B(\$id,where)\ ==\ \"peg\"\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\$B(\$id,step)\ >=\ \$S(psteps)\}\ \{\ \ \ \ \ \ \ \ \;#\ Hit\ the\ next\ peg\n\ \ \ \ \ \ \ \ \ \ \ \ lassign\ \[split\ \$B(\$id,peg)\ \",\"\]\ col\ row\n\ \ \ \ \ \ \ \ \ \ \ \ incr\ col\ \$B(\$id,dir)\n\ \ \ \ \ \ \ \ \ \ \ \ incr\ row\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$row\ >=\ \$S(rows)\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Off\ the\ bottom\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$SUMS(\$col)\ ==\ \"\"\}\ \{set\ SUMS(\$col)\ 0\}\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ incr\ SUMS(\$col)\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ array\ unset\ B\ \$id,*\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ .c\ delete\ \$id\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$S(sound)\}\ \{snd_click\ play\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,peg)\ \"\$col,\$row\"\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,dir)\ \[expr\ \{rand()\ <\ (\$S(bias)\ +\ 10)/20.0\ ?\ 1\ :\ -1\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ set\ B(\$id,step)\ 0\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ set\ xy\ \[Ball2Canvas\ \$id\]\n\ \ \ \ MoveAbs\ \$id\ \$xy\n\}\nproc\ MoveOneBall\ \{id\ \{single\ 0\}\}\ \{\n\ \ \ \ global\ B\ S\n\n\ \ \ \ set\ ttime\ \[clock\ clicks\ -milliseconds\]\n\ \ \ \ if\ \{!\ \[info\ exists\ B(\$id,peg)\]\}\ return\n\ \ \ \ if\ \{\$S(stop)\ &&\ !\ \$single\}\ return\n\ \ \ \ MoveBall\ \$id\n\ \ \ \ if\ \{\$single\}\ return\n\ \ \ \ set\ ttime\ \[expr\ \{\[clock\ clicks\ -milliseconds\]\ -\ \$ttime\}\]\n\ \ \ \ set\ delay\ \[expr\ \{110\ -\ 10*\$S(speed)\}\]\n\ \ \ \ set\ delay\ \[expr\ \{\$ttime\ >\ \$delay\ ?\ 0\ :\ \$delay\ -\ \$ttime\}\]\n\ \ \ \ after\ \$delay\ \[list\ MoveOneBall\ \$id\]\n\}\nproc\ Go\ \{\}\ \{\n\ \ \ \ global\ B\ S\n\n\ \ \ \ if\ \{\$S(stop)\}\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ We're\ stopped\n\ \ \ \ \ \ \ \ .go\ config\ -text\ \"Stop\"\n\ \ \ \ \ \ \ \ set\ S(stop)\ 0\n\ \ \ \ \ \ \ \ foreach\ ball\ \[array\ names\ B\ *,xy\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ id\ \[lindex\ \[split\ \$ball\ \",\"\]\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ after\ \[expr\ \{110\ -\ 10*\$S(speed)\}\]\ \[list\ MoveOneBall\ \$id\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ Birth\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ foreach\ a\ \[after\ info\]\ \{after\ cancel\ \$a\}\n\ \ \ \ \ \ \ \ .go\ config\ -text\ \"Go\"\n\ \ \ \ \ \ \ \ set\ S(stop)\ 1\n\ \ \ \ \}\n\}\nproc\ Clear\ \{\}\ \{\n\ \ \ \ set\ stop\ \$::S(stop)\n\ \ \ \ if\ \{!\ \$stop\}\ Go\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Stop\ everything\n\ \ \ \ foreach\ a\ \[array\ names\ ::SUMS\]\ \{\ set\ ::SUMS(\$a)\ \"\"\ \}\n\ \ \ \ foreach\ a\ \[array\ names\ ::B\]\ \{\ unset\ ::B(\$a)\ \}\n\ \ \ \ .c\ delete\ ball\n\ \ \ \ if\ \{!\ \$stop\}\ Go\n\}\nproc\ Birth\ \{\}\ \{\n\ \ \ \ global\ S\n\n\ \ \ \ if\ \{\$S(stop)\ ||\ !\ \$S(auto)\}\ return\n\ \ \ \ CreateBall\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Called\ for\ a\ new\ birth\n\ \ \ \ NewBirth\ \$S(birth)\n\}\nproc\ NewBirth\ \{val\}\ \{\n\ \ \ \ global\ S\n\n\ \ \ \ after\ cancel\ Birth\n\ \ \ \ set\ rate\ \[expr\ \{103\ -\ \$S(birth)\}\]\n\ \ \ \ set\ delay\ \[expr\ \{110\ -\ 10*\$S(speed)\}\]\n\ \ \ \ set\ delay\ \[expr\ \{\$delay\ *\ \$rate\ +\ round(200\ *\ rand())\}\]\n\ \ \ \ after\ \$delay\ Birth\n\}\nproc\ DoSounds\ \{\}\ \{\n\ \ \ \ proc\ snd_click\ \{play\}\ \{\}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Stub\n\ \ \ \ if\ \{\[catch\ \{package\ require\ base64\}\]\}\ return\n\ \ \ \ if\ \{\[catch\ \{package\ require\ snack\}\]\}\ return\n\ \ \ \ set\ sdata\ \{UklGRkACAABXQVZFZm10IBAAAAABAAEAESsAABErAAABAAgAZGF0YRwCAACAgId0Z\n\ \ \ \ \ \ \ \ HZbU5aMj7/MsIZ6UX6nWIiITWiIRUGUlZesvrGCiKiKTl96Fit3YF5emrGHqcqhlJuAdWxgW\n\ \ \ \ \ \ \ \ 01EbWSHubW1uJ2MkqGPYFVSamtvgHmEh5ybraWLkHp5Xm5oWGRvb3WSlYqMi4+JhY6Ac25xd\n\ \ \ \ \ \ \ \ Xp5jYR/hoODdIN8e356goCHgoqGgIV/g35/d3N2eHZ6gIOIgouHioaNioGAfHpycHp2dH2Hi\n\ \ \ \ \ \ \ \ ouNiYiKhIF9enZzd3l+dX2BgYKIjoaJhIJ/fX6AfHl8fICAgICEgISFhYF/gH+AfIJ/gH6Af\n\ \ \ \ \ \ \ \ X6AfICAfYB+gn2DfoGAgIOAgYB8e3x9gIKChYCDgIN/g32Afn+BgIF+gH+BgIOAgX2CfYGAg\n\ \ \ \ \ \ \ \ IB/gH9/fIB/gICBgH+Df4KAgIB9gHuBfYKAgoCAhICDgIN+gH+Af4CAgIGAg4CFgIOAgICAg\n\ \ \ \ \ \ \ \ H9/f32AfoF/gn+BgICAf4B/gICAgICAgIKAgYCAgH+AfYB8f4CAgoGBgIKBgHt0cnqEi4yIh\n\ \ \ \ \ \ \ \ oKHioOBeoF+gHRvbW10eYSHhoyMmI+PhIF5dm9tbW92fICJjpKRkY6JhHx5b2xlbnWAhYeOj\n\ \ \ \ \ \ \ \ pSQkIiAe3R1cnNzdnx/gomLj4yJhICAfHp3d3d6fYKDhoKGgIeAhX1/eXt9foCAg4GCg4CDf\n\ \ \ \ \ \ \ \ YF6gHmAfYCBgIR/h4CEf4B9fn98gHuEfYV/g4CAgn6Fe4R6gn1/gHuDe4V+g4CAgn8=\}\n\ \ \ \ regsub\ -all\ \{\\s\}\ \$sdata\ \{\}\ sdata\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;#\ Bug\ in\ base64\ package\n\ \ \ \ sound\ snd_click\n\ \ \ \ snd_click\ data\ \[::base64::decode\ \$sdata\]\n\ \ \ \ .sound\ config\ -state\ normal\n\}\n\nDoDisplay\n----\n\[GN\]\ 2004-07-30\ :\ wow\ -\ Uses\ 80%\ +\ of\ my\ dual\ 2.0G5s\ cpu\ in\ max\ speed\n\n<<categories>>\ Graphics\ |\ Application\ |\ Whizzlet\ |\ Animation} CALL {my revision {Falling Marbles}} CALL {::oo::Obj957540 process revision/Falling+Marbles} CALL {::oo::Obj957538 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4