#!/users/mgd/packages/swarm/blt2.3/bin/bltwish
#!../bltwish

source bltDemo.tcl

set graph .graph

bitmap define pattern1 { {4 4} {01 02 04 08} }
bitmap define pattern5 { {4 4} {01 01 01 01} }

set visual [winfo screenvisual .]
if { $visual != "staticgray" && $visual != "grayscale" } {
    option add *Button.Background		red
    option add *TextMarker.Foreground	black
    option add *TextMarker.Background	yellow
    option add *LineMarker.Foreground	black
    option add *LineMarker.Background	yellow
    option add *PolyMarker.Fill		yellow2
    option add *PolyMarker.Outline	""
    option add *PolyMarker.Stipple	pattern5
    option add *activeLine.Color	red4
    option add *activeLine.Fill		red2
    option add *Element.Color		purple
}

option add *HighlightThickness		0

image create photo bgTexture -file bitmaps/chalk.gif

option add *Text.font			-*-times*-bold-r-*-*-18-*-*
option add *header.font			-*-times*-medium-r-*-*-18-*-*
option add *footer.font			-*-times*-medium-r-*-*-18-*-*

option add *Tile		bgTexture
option add *Button.Tile		""

option add *Graph.halo         8i
#option add *Graph.bufferElements no
#option add *Graph.invertXY 	1
#option add *Graph.PlotPad 	0.25i
option add *Graph.title 	"Trig Functions" 
option add *Graph.width 	8i
option add *Graph.height 	6i
option add *Graph.borderWidth 	1
option add *Graph.relief	sunken
option add *Graph.font 		-*-helvetica-bold-r-*-*-18-*-*-*-*-*-*-* 

option add *Axis.TickFont 	-*-helvetica-bold-r-*-*-12*-*-*-*-*-*-* 
option add *Axis.TitleFont 	-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*
option add *Axis.hide 		no
option add *x.stepSize		90 
option add *x.Command		formatXLabels 
option add *x.Subdivisions	0 
option add *x.Title		"X" 
option add *y.Title		"Y" 
option add *y.Loose		no
option add *y.Color		purple2
option add *y.rotate		90 
option add *y2.color		magenta3

option add *Legend.Position 	right
option add *Legend.Anchor 	ne
option add *Legend.activeRelief raised
option add *Legend.activeBorderWidth 2
option add *Legend.font		-*-helvetica-medium-r-*-*-24-*-*-*-*-*-*-*
option add *Legend.font		fixed

option add *Element.ScaleSymbols yes
option add *Element.Pixels	1.75m

text .header -wrap word -width 0 -height 3

set text {
This is an example of a bitmap marker.  Try zooming in on 
a region by clicking the left button, moving the pointer, 
and clicking again.  Notice that the bitmap scales too. 
To restore the last view, click on the right button.  
}

regsub -all "\n" $text "" text
.header insert end "$text\n"
.header configure -state disabled

htext .footer -text {Hit the %%
    set im [image create photo -file bitmaps/stopsign.gif]
    button $htext(widget).quit -image $im -command { exit }
    $htext(widget) append $htext(widget).quit 
%% button when you've seen enough. %%
    label $htext(widget).logo -bitmap BLT
    $htext(widget) append $htext(widget).logo 
%%}

graph .graph

proc formatXLabels {graph x} {
     return "[expr int($x)]\260"
}

table . \
    .header 0,0 -fill x -padx 4 -pady 4\
    .graph 1,0 -fill both  \
    .footer 2,0 -fill x -padx 4 -pady 4

table configure . r0 r2 -resize none

vector w x sinx cosx

set tcl_precision 15
.graph element create line1 \
    -label sin(x) -fill orange -color black -xdata x -ydata sinx  

.graph element create line2 \
    -label cos(x) -color yellow4 -fill yellow -xdata x -ydata cosx 


set pi1_2 [expr 3.14159265358979323846/180.0]

puts stderr "Generating data..."
for { set i -360 } { $i <= 360 } { incr i 5 } {
    set x(++end) $i 
    set radians [expr $i*$pi1_2]
    set sinx(++end) sin($radians)
    set cosx(++end) cos($radians)
}

puts stderr "done."

Blt_ZoomStack $graph
Blt_Crosshairs $graph
Blt_ActiveLegend $graph
Blt_ClosestPoint $graph
Blt_PrintKey $graph


.graph marker create bitmap -name bg -coords "-360 -1 360 1" \
	-bitmap @bitmaps/greenback \
	-bg seagreen2 -fg green4 -under true

.graph postscript configure -maxpect yes -landscape yes
