home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.0 / stk-3 / blt-for-STk-3.0 / blt-1.9 / demos / graph2 < prev    next >
Encoding:
Text File  |  1995-07-01  |  2.7 KB  |  92 lines

  1. #!../blt_wish -f
  2.  
  3. if [file exists ../library] {
  4.     set blt_library ../library
  5. }
  6.  
  7. blt_bitmap define pattern1 { {4 4} {01 02 04 08} }
  8. blt_bitmap define pattern5 { {4 4} {01 01 01 01} }
  9. option add *Blt_graph.font *New*Century*Bold*R*14* 
  10. option add *Blt_htext.Font *Times*Bold-R*14*
  11. option add *Blt_graph.textFont *new*century*140*
  12.  
  13. set visual [winfo screenvisual .]
  14. if { $visual != "staticgray" && $visual != "grayscale" } {
  15.     option add *Button.Background red
  16.     option add *Blt_graph.foreground navyblue
  17.     option add *Blt_graph.borderWidth 2
  18.     option add *Blt_graph.relief sunken 
  19.     option add *Blt_graph.textTagForeground black
  20.     option add *Blt_graph.textTagBackground yellow
  21.     option add *Blt_graph.lineTagForeground black
  22.     option add *Blt_graph.lineTagBackground yellow
  23.     option add *Blt_graph.polyTagForeground lightblue
  24.     option add *Blt_graph.polyTagStipple pattern5
  25.     option add *Blt_graph.polyTagBackground {}
  26.     option add *Blt_graph.elemActiveBackground yellow
  27.     option add *Blt_graph.elemActiveForeground brown 
  28. }
  29.  
  30. option add *Blt_graph.title         "Another XY Graph"
  31. option add *Blt_graph.xTitle         "X Axis Label"
  32. option add *Blt_graph.yTitle         "Y Axis Label"
  33. option add *Blt_graph.elemScale       0.85
  34.  
  35. blt_htext .msg -text {\
  36. In this example, you can sweep out a box to zoom in by clicking with 
  37. the left button and dragging the pointer.  To restore the original view,
  38. simply click on the middle button.  
  39. Hit the %%
  40. button $blt_htext(widget).quit -text {Quit} -command {exit} 
  41. $blt_htext(widget) append $blt_htext(widget).quit
  42. %% button when you've seen enough. %%
  43. label $blt_htext(widget).logo -bitmap BLT 
  44. $blt_htext(widget) append $blt_htext(widget).logo
  45. %%}
  46.  
  47. blt_graph .graph
  48.  
  49. .graph xaxis configure -step 90 -command formatXLabels -subticks 0 
  50. .graph yaxis configure -rotate 90.0 
  51.  
  52. proc formatXLabels {graph x} {
  53.      return "[expr int($x)]\260"
  54. }
  55.  
  56. .graph element create sin(x) \
  57.     -symbol circle \
  58.     -bg powderblue \
  59.     -fg navyblue \
  60.     -linewidth 2 
  61.  
  62. .graph element create cos(x) \
  63.     -symbol circle \
  64.     -fg magenta \
  65.     -bg purple \
  66.     -borderwidth 1 \
  67.     -linewidth 2 
  68.  
  69. pack append .  \
  70.     .graph { fill expand } \
  71.     .msg  { padx 20 pady 10 } 
  72. wm min . 0 0
  73.  
  74. set x [expr 3.14159265358979323846/180.0]
  75. puts stderr "Generating data..."
  76. for { set i -360 } { $i <= 360 } { incr i 5 } {
  77.     set radians [expr $i*$x]
  78.     .graph element append sin(x) { $i sin($radians) }
  79.     .graph element append cos(x) { $i cos($radians) }
  80. }
  81. puts stderr "done."
  82.  
  83. set sine [lindex [.graph element configure sin(x) -data] 4]
  84. set fill [concat -360 min $sine 360 min]
  85. .graph tag create polygon $fill
  86.  
  87. source features.tcl
  88. SetActiveLegend .graph
  89. SetClosestPoint .graph
  90. SetZoom .graph
  91. SetPrint .graph
  92.