blob: fa0126b423097ad8b3b669b65f5025b6febe3065 (
plain)
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
32
33
34
35
36
37
38
39
40
41
|
package main
import (
"log"
"os"
)
func main() {
fd, err := os.Open("teapot.dat")
if err != nil {
log.Fatal(err)
}
defer fd.Close()
patches := Parse(fd)
out := NewOut(os.Stdout)
out.Clear()
out.Enable()
defer out.Disable()
step := 1.0 / float64(5)
for _, p := range patches {
for u := 0.0; u <= 1.0; u += step {
out.PenDown()
for v := 0.0; v <= 1.0; v += step {
vertex := Calc(u, v, p)
x, y := vertex.Project()
out.Draw(x, y)
}
out.PenUp()
out.PenDown()
for v := 0.0; v <= 1.0; v += step {
vertex := Calc(v, u, p)
x, y := vertex.Project()
out.Draw(x, y)
}
out.PenUp()
}
}
}
|