| 1 |
#!/bin/sh |
| 2 |
# next line is a comment in tcl \ |
| 3 |
exec tclsh "$0" ${1+"$@"} |
| 4 |
|
| 5 |
package require Gdtclft |
| 6 |
|
| 7 |
################################################################ |
| 8 |
# Sample gdtcl program - from gdtclft man page |
| 9 |
# |
| 10 |
# Create a 64 x 64 image |
| 11 |
set im [gd create 64 64] |
| 12 |
|
| 13 |
# Get black and white as colors. Black is the background color because |
| 14 |
# it is allocated first from a new image. |
| 15 |
|
| 16 |
set black [gd color new $im 0 0 0] |
| 17 |
set white [gd color new $im 255 255 255] |
| 18 |
|
| 19 |
# Draw a line from upper left to lower right |
| 20 |
gd line $im $white 0 0 63 63 |
| 21 |
|
| 22 |
# Open a file for writing (Tcl on Unix, at least, doesn't support 'wb' mode) |
| 23 |
set out [open test.png w] |
| 24 |
|
| 25 |
# Output the image to the disk file |
| 26 |
gd writePNG $im $out |
| 27 |
|
| 28 |
# Close the file |
| 29 |
close $out |
| 30 |
|
| 31 |
# Destroy the image in memory |
| 32 |
gd destroy $im |
| 33 |
|