| 1 |
#!../src/bltwish |
| 2 |
|
| 3 |
package require BLT |
| 4 |
# -------------------------------------------------------------------------- |
| 5 |
# Starting with Tcl 8.x, the BLT commands are stored in their own |
| 6 |
# namespace called "blt". The idea is to prevent name clashes with |
| 7 |
# Tcl commands and variables from other packages, such as a "table" |
| 8 |
# command in two different packages. |
| 9 |
# |
| 10 |
# You can access the BLT commands in a couple of ways. You can prefix |
| 11 |
# all the BLT commands with the namespace qualifier "blt::" |
| 12 |
# |
| 13 |
# blt::graph .g |
| 14 |
# blt::table . .g -resize both |
| 15 |
# |
| 16 |
# or you can import all the command into the global namespace. |
| 17 |
# |
| 18 |
# namespace import blt::* |
| 19 |
# graph .g |
| 20 |
# table . .g -resize both |
| 21 |
# |
| 22 |
# -------------------------------------------------------------------------- |
| 23 |
if { $tcl_version >= 8.0 } { |
| 24 |
namespace import blt::* |
| 25 |
namespace import -force blt::tile::* |
| 26 |
} |
| 27 |
source scripts/demo.tcl |
| 28 |
|
| 29 |
option add *graph.Element.ScaleSymbols true |
| 30 |
|
| 31 |
# test to show spline over-shooting |
| 32 |
|
| 33 |
set tcl_precision 15 |
| 34 |
|
| 35 |
# Make and fill small vectors |
| 36 |
vector create x y |
| 37 |
x seq 10 0 -0.5 |
| 38 |
y expr sin(x^3) |
| 39 |
x expr x*x |
| 40 |
x sort y |
| 41 |
vector create x2 y1 y2 y3 |
| 42 |
|
| 43 |
# make and fill (x only) large vectors |
| 44 |
x populate x2 10 |
| 45 |
|
| 46 |
# natural spline interpolation |
| 47 |
spline natural x y x2 y1 |
| 48 |
|
| 49 |
# quadratic spline interpolation |
| 50 |
spline quadratic x y x2 y2 |
| 51 |
|
| 52 |
# make plot |
| 53 |
graph .graph |
| 54 |
.graph xaxis configure -title "x^2" |
| 55 |
.graph yaxis configure -title "sin(y^3)" |
| 56 |
|
| 57 |
.graph pen configure activeLine -pixels 5 |
| 58 |
.graph element create Original -x x -y y \ |
| 59 |
-color red4 \ |
| 60 |
-fill red \ |
| 61 |
-pixels 5 \ |
| 62 |
-symbol circle |
| 63 |
|
| 64 |
.graph element create Natural -x x2 -y y1 \ |
| 65 |
-color green4 \ |
| 66 |
-fill green \ |
| 67 |
-pixels 3 \ |
| 68 |
-symbol triangle |
| 69 |
|
| 70 |
.graph element create Quadratic -x x2 -y y2 \ |
| 71 |
-color blue4 \ |
| 72 |
-fill orange2 \ |
| 73 |
-pixels 3 \ |
| 74 |
-symbol arrow |
| 75 |
|
| 76 |
table . .graph -fill both |
| 77 |
|
| 78 |
Blt_ZoomStack .graph |
| 79 |
Blt_Crosshairs .graph |
| 80 |
Blt_ActiveLegend .graph |
| 81 |
Blt_ClosestPoint .graph |
| 82 |
Blt_PrintKey .graph |
| 83 |
|
| 84 |
.graph grid on |