| 1 |
option add *HighlightThickness 0 |
| 2 |
option add *Tile bgTexture |
| 3 |
option add *Button.Tile "" |
| 4 |
|
| 5 |
image create photo bgTexture -file ./images/chalk.gif |
| 6 |
|
| 7 |
set configOptions [subst { |
| 8 |
InvertXY no |
| 9 |
Axis.TickFont { Helvetica 14 bold } |
| 10 |
Axis.TitleFont { Helvetica 12 bold } |
| 11 |
BorderWidth 2 |
| 12 |
Element.Pixels 8 |
| 13 |
Element.ScaleSymbols true |
| 14 |
Element.Smooth cubic |
| 15 |
Font { Helvetica 18 bold } |
| 16 |
Foreground white |
| 17 |
Legend.ActiveBorderWidth 2 |
| 18 |
Legend.ActiveRelief raised |
| 19 |
Legend.Anchor ne |
| 20 |
Legend.BorderWidth 0 |
| 21 |
Legend.Font { Helvetica 34 } |
| 22 |
Legend.Foreground orange |
| 23 |
#Legend.Position plotarea |
| 24 |
Legend.Hide yes |
| 25 |
Legend.Relief flat |
| 26 |
Postscript.Preview yes |
| 27 |
Relief raised |
| 28 |
Shadow { navyblue 2 } |
| 29 |
Title "Bitmap Symbols" |
| 30 |
degrees.Command [namespace current]::FormatAxisLabel |
| 31 |
degrees.LimitsFormat "Deg=%g" |
| 32 |
degrees.Subdivisions 0 |
| 33 |
degrees.Title "Degrees" |
| 34 |
degrees.stepSize 90 |
| 35 |
temp.LimitsFormat "Temp=%g" |
| 36 |
temp.Title "Temperature" |
| 37 |
y.Color purple2 |
| 38 |
y.LimitsFormat "Y=%g" |
| 39 |
y.Rotate 90 |
| 40 |
y.Title "Y" |
| 41 |
y.loose no |
| 42 |
y2.Color magenta3 |
| 43 |
y2.Hide no |
| 44 |
xy2.Rotate 270 |
| 45 |
y2.Rotate 0 |
| 46 |
y2.Title "Y2" |
| 47 |
y2.LimitsFormat "Y2=%g" |
| 48 |
x2.LimitsFormat "x2=%g" |
| 49 |
}] |
| 50 |
|
| 51 |
set resource [string trimleft $graph .] |
| 52 |
foreach { option value } $configOptions { |
| 53 |
option add *$resource.$option $value |
| 54 |
} |
| 55 |
|
| 56 |
proc FormatAxisLabel {graph x} { |
| 57 |
format "%d%c" [expr {int($x)}] 0xB0 |
| 58 |
} |
| 59 |
|
| 60 |
set max -1.0 |
| 61 |
set step 0.2 |
| 62 |
|
| 63 |
set letters { A B C D E F G H I J K L } |
| 64 |
set count 0 |
| 65 |
for { set level 30 } { $level <= 100 } { incr level 10 } { |
| 66 |
set color [format "#dd0d%0.2x" [expr round($level*2.55)]] |
| 67 |
set pen "pen$count" |
| 68 |
set symbol "symbol$count" |
| 69 |
bitmap compose $symbol [lindex $letters $count] \ |
| 70 |
-font -*-helvetica-medium-r-*-*-34-*-*-*-*-*-*-* |
| 71 |
$graph pen create $pen \ |
| 72 |
-color $color \ |
| 73 |
-symbol $symbol \ |
| 74 |
-fill "" \ |
| 75 |
-pixels 13 |
| 76 |
set min $max |
| 77 |
set max [expr $max + $step] |
| 78 |
lappend styles "$pen $min $max" |
| 79 |
incr count |
| 80 |
} |
| 81 |
|
| 82 |
$graph axis create temp \ |
| 83 |
-color lightgreen \ |
| 84 |
-title Temp |
| 85 |
$graph axis create degrees \ |
| 86 |
-rotate 90 |
| 87 |
$graph xaxis use degrees |
| 88 |
|
| 89 |
set tcl_precision 15 |
| 90 |
set pi1_2 [expr 3.14159265358979323846/180.0] |
| 91 |
|
| 92 |
vector create w x sinX cosX radians |
| 93 |
x seq -360.0 360.0 10.0 |
| 94 |
#x seq -360.0 -180.0 30.0 |
| 95 |
if {[catch { |
| 96 |
vector op expr radians { x * $pi1_2 } |
| 97 |
vector op expr sinX sin(radians) |
| 98 |
vector op expr cosX cos(radians) |
| 99 |
}]} { |
| 100 |
tclLog "new 'op' subcmd unavailable." |
| 101 |
radians expr { x * $pi1_2 } |
| 102 |
sinX expr sin(radians) |
| 103 |
cosX expr cos(radians) |
| 104 |
cosX dup w |
| 105 |
} |
| 106 |
vector destroy radians |
| 107 |
vector create xh xl yh yl |
| 108 |
set pct [expr {($cosX(max) - $cosX(min)) * 0.025}] |
| 109 |
yh expr {cosX + $pct} |
| 110 |
yl expr {cosX - $pct} |
| 111 |
set pct [expr ($x(max) - $x(min)) * 0.025] |
| 112 |
xh expr {x + $pct} |
| 113 |
xl expr {x - $pct} |
| 114 |
|
| 115 |
$graph element create line3 \ |
| 116 |
-color green4 \ |
| 117 |
-fill green \ |
| 118 |
-label "cos(x)" \ |
| 119 |
-mapx degrees \ |
| 120 |
-styles $styles \ |
| 121 |
-weights w \ |
| 122 |
-x x \ |
| 123 |
-y cosX \ |
| 124 |
-yhigh yh -ylow yl |
| 125 |
|
| 126 |
$graph element create line1 \ |
| 127 |
-color orange \ |
| 128 |
-outline black \ |
| 129 |
-fill orange \ |
| 130 |
-fill yellow \ |
| 131 |
-label "sin(x)" \ |
| 132 |
-linewidth 3 \ |
| 133 |
-mapx degrees \ |
| 134 |
-pixels 6m \ |
| 135 |
-symbol "@bitmaps/hobbes.xbm @bitmaps/hobbes_mask.xbm" \ |
| 136 |
-x x \ |
| 137 |
-y sinX |
| 138 |
|
| 139 |
Blt_ZoomStack $graph |
| 140 |
Blt_Crosshairs $graph |
| 141 |
#Blt_ActiveLegend $graph |
| 142 |
Blt_ClosestPoint $graph |
| 143 |
Blt_PrintKey $graph |
| 144 |
|