File: testfunc.tcl

package info (click to toggle)
tklib 0.6-1%2Bdeb8u1
  • links: PTS
  • area: main
  • in suites: jessie
  • size: 16,112 kB
  • ctags: 4,008
  • sloc: tcl: 65,204; sh: 6,870; ansic: 792; pascal: 359; makefile: 73; exp: 21; sed: 16
file content (27 lines) | stat: -rwxr-xr-x 674 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# testfunc.tcl --
#     Test the plotfunc method
#
source plotchart.tcl
package require Plotchart

grid [canvas .c -width 500 -height 500]

set p [::Plotchart::createXYPlot .c {-4.0 4.0 2.0} {-4.0 4.0 2.0}]

proc parabola {a x} {
    expr {$a**2 - $x**2}
}
proc semicircle {a x} {
    expr {sqrt($a**2 - $x**2)}
}
proc hyperbola {a x} {
    expr {sqrt($x**2 - $a**2)}
}

$p plotfunc parabola {x a} {[parabola $a $x]} 2.0

$p dataconfig semicircle -colour red -width 2
$p plotfunc semicircle {x a} {[semicircle $a $x]} 2.0 -samples 100

$p dataconfig hyperbola -colour blue -width 2
$p plotfunc hyperbola {x a} {[hyperbola $a $x]} 1.0 -samples 100