#!/usr/local/contrib/bin/wish #Animation: repeatedly moving parts from "Assembly line" to "Post" # Create main canvas canvas .cmain -width 590 -height 150 -background red # pack propagate .cmain false pack .cmain # Create canvas c1 canvas .cmain.c1 -width 590 -height 150 -background white canvas .cmain.c1.cl -width 80 -height 80 -background red canvas .cmain.c1.cr -width 80 -height 80 -background red # pack propagate .cmain.c1.cr false pack .cmain.c1.cr -side right -padx 10 pack propagate .cmain.c1.cl false pack .cmain.c1.cl -side left -padx 100 label .cmain.c1.cr.l2 -font {{Times New Roman} 10 {bold roman}} -text "Assembly Line" pack .cmain.c1.cr.l2 -pady 30 label .cmain.c1.cl.l1 -font {{Times New Roman} 10 {bold roman}} -text "Post" pack .cmain.c1.cl.l1 -pady 30 pack propagate .cmain.c1 false pack .cmain.c1 -side top # Create ball for canvas c1 # Create moving Object for canvas 1 proc new_ball1 {xpos ypos speed color} { .cmain.c1 create rectangle 500 50 450 100 -fill $color -tag "ball-$ypos" move1 $xpos $ypos $speed label .cmain.c1.l1 -font {{Times New Roman} 10 {bold roman}} -text "Kanban Card" pack .cmain.c1.l1 } #repeatedly moving object from initPostion to the destination proc move1 {xpos ypos speed} { global toInitPosition initPosition if {$toInitPosition != 1} { .cmain.c1 move "ball-$ypos" [expr -$speed] 0 } else { .cmain.c1 move "ball-$ypos" [expr $initPosition+225] 0 set toInitPosition 0 } set xpos [expr $xpos-$speed] if {$xpos < -220} { set xpos 100 set toInitPosition 1 } after 300 [list move1 $xpos $ypos $speed] } #Introduce next two global variable in order to repeat the ball-1 set toInitPosition 0 set initPosition 100 new_ball1 $initPosition 60 10 blue