File: testfunc.tcl

package info (click to toggle)
tklib 0.6%2B20190108-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,008 kB
  • sloc: tcl: 75,757; sh: 5,789; ansic: 792; pascal: 359; makefile: 70; sed: 53; exp: 21
file content (31 lines) | stat: -rwxr-xr-x 683 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
28
29
30
31
#!/usr/bin/env tclsh
## -*- tcl -*-

package require Tk

# testfunc.tcl --
#     Test the plotfunc method
#
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