You are here

Gd 0.4.0.3

admin의 아바타
첨부 파일파일 크기
Package icon gd842.zip297.41 KB

홈페이지 : http://www.du.edu/~mschwart/tcl-tk.htm

PNG, JPEG file production Nearly identical interface to GDI Windows & Unix

Example

#!/usr/local/bin/tclsh8.0 -f
#
# This example builds a barchart from sample data
# (this is the sort of application one might have in mind for building live web displays)
#
# Sorry it doesn't do this with a set of procedures....
#
# The hardest thing to understand about the example is that the units for the image
# start at 0 on the TOP of the image. This makes everything else seem "upside down"
#
if [ catch { package require gd } err ] {
  load gd.dll
}

set data {
  { 1990    27.2 }
  { 1991    31.6 }
  { 1992    35.0 }
  { 1993    22.1 }
  { 1994    12.0 }
  { 1995    26.1 }
  { 1996    30.1 }
  { 1997    41.2 }
}

set width 640
set height 480

# Get some data information prepared: How many items, and min/max range
set numitems [ llength $data ]
set itemwid  [ expr round ( ( $width - 40 ) / $numitems ) ]

set min [ lindex [ lindex $data 0 ] 1 ]
set max $min

foreach row $data { 
  set val [ lindex $row 1 ]
  if { $val > $max } {
    set max $val
  } elseif { $val