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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
|
|
|
|
|
|
|
|
-
-
|
!
!
-
|
|
!
-
|
|
!
|
#module BSpline2
#deffunc bsArgo@BSpline2 int x1, int y1, int x2, int y2, int x3, int y3, local k, local t
pos x1, y1
repeat 100, 1
t = double(cnt)/100
k = 1.0 - t
line k * k * x1 + 2.0 * t * k * x2 + t * t * x3, k * k * y1 + 2.0 * t * k * y2 + t * t * y3
loop
return
#deffunc bsDrawLine local xCurrent, local yCurrent
if count > 3 {
bsArgo x(0), y(0), x(1), y(1), (x(1) + x(2))/2, (y(1) + y(2))/2
xCurrent = (x(1) + x(2))/2 : yCurrent = (y(1) + y(2))/2
repeat count - 4, 2
xNext = (x(cnt) + x(cnt + 1))/2 : yNext = (y(cnt) + y(cnt + 1))/2
bsArgo xCurrent, yCurrent, x(cnt), y(cnt), xNext, yNext
xCurrent = xNext : yCurrent = yNext
loop
bsArgo xCurrent, yCurrent, x(count - 2), y(count - 2), x(count - 1), y(count - 1)
} else {
if count == 3 {
bsArgo x(0), y(0), x(1), y(1), x(2), y(2)
}
}
return
#deffunc bsDrawPoint
repeat count
circle x(cnt) - 2, y(cnt) - 2, x(cnt) + 2, y(cnt) + 2
loop
return
#deffunc bsAdd int x1, int y1
x(count) = x1 : y(count) = y1 : count++
return count
#deffunc bsClear
count = 0
return
#global
bsClear
onclick *addPoint
stop
*addPoint
if iparam == 0 {
bsAdd lparam & $FFFF, lparam >> 16
}
if iparam == 3{
bsClear
}
gosub *draw
stop
*draw
redraw 0
color 255, 255, 255
boxf
color 255
bsDrawPoint
color
bsDrawLine
redraw 1
return
|