home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / TCL / BLT / BLT1.7L1 / BLT1 / blt-1.7 / applications / extloader / demos / blt / graph2 < prev    next >
Encoding:
Text File  |  1994-04-22  |  2.7 KB  |  91 lines

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