Re:Girls and Computers
by pwg on Tuesday March 27, 2012 @07:20AM
(#3760938)
> Doing graphics in Linux is a PITA.
How so? Almost every Linux distro comes with Tcl/Tk (if not installed by default, installable by checking a box in a package manager). Using the Tk canvas widget your basic code above becomes:
$ wish <- start a live Tcl/Tk REPL
canvas .c
pack .c -expand true -fill both
.c create rectangle 100 100 200 100 -fill white
.c create rectangle 200 100 200 200 -fill white
.c create rectangle 100 200 200 200 -fill white
.c create rectangle 100 100 100 200 -fill white
for {set i 100} {$i <= 200} {incr i 10} {
for {set k 200} {$k <= 100} {incr k -10} {
.c create rectangle $i $k $k $i -fill blue
.c create rectangle $k $i $i $k -fill green
}
}
All with the added advantage that you can watch the drawing happen as you type in the code instead of waiting until the end to enter "run". Note, I have assumed your "DRAW" statements draw rectangles because they have four coordinates. The canvas widget supports many more shapes than just basic rectangles, substitute as desired.
How so? Almost every Linux distro comes with Tcl/Tk (if not installed by default, installable by checking a box in a package manager). Using the Tk canvas widget your basic code above becomes:
$ wish <- start a live Tcl/Tk REPL
All with the added advantage that you can watch the drawing happen as you type in the code instead of waiting until the end to enter "run". Note, I have assumed your "DRAW" statements draw rectangles because they have four coordinates. The canvas widget supports many more shapes than just basic rectangles, substitute as desired.