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
79
80
|
-
|
|
|
!
-
|
|
|
|
!
|
#module i_Line
#define a dimension(0)
#define b dimension(1)
#define c dimension(2)
#define d dimension(3)
#define e dimension(4)
#define f dimension(5)
#define g dimension(6)
#define h dimension(7)
#defcfunc is_crossing array dimension, local t, local u
if double(d-b)/(g-e) = double(h-f)*(c-a) : return 0
t = double((e-g)*(b-f)-(f-h)*(a-e))/((c-a)*(f-h)-(d-b)*(e-g))
u = -double((c-a)*(b-f)-(d-b)*(a-e))/((c-a)*(f-h)-(d-b)*(e-g))
if (limitf(t,0.0,1.0) = t) & (limitf(u,0.0,1.0) = u) : return 1
return 0
#defcfunc cross_x array dimension, local t
t = double((e-g)*(b-f)-(f-h)*(a-e))/((c-a)*(f-h)-(d-b)*(e-g))
return double(c-a)*t+a
#defcfunc cross_y array dimension, local t
t = double((e-g)*(b-f)-(f-h)*(a-e))/((c-a)*(f-h)-(d-b)*(e-g))
return double(d-b)*t+b
#global
#define ctype LA(%1) liner(0,%1)
#define ctype LB(%1) liner(1,%1)
#define ctype LC(%1) liner(2,%1)
#define ctype LD(%1) liner(3,%1)
quickmode = 0
dim liner, 4, 1
liner(0,0) = 0, 0, 640, 480
line_draw 0
repeat
wait 3
getkey br, 1
if quickmode = br : continue
quickmode = br
if quickmode = 1 {
sx = mousex
sy = mousey
continue
}
new_line length2(liner)
loop
stop
#deffunc line_draw int index
color
line LA(index), LB(index), LC(index), LD(index)
return
#deffunc new_line int index
if (sx=mousex) & (sy=mousey) : return
liner(0,index) = sx, sy, mousex, mousey
line_draw index
repeat index
cross_draw index, cnt
loop
return
#deffunc cross_draw int i1, int i2, local dimension \
, local x, local y
dim dimension, 8
memcpy dimension, liner(0,i1), 4*4, 0, 0
memcpy dimension, liner(0,i2), 4*4, 4*4, 0
if is_crossing(dimension) {
color 255, 255, 0
x = cross_x(dimension)
y = cross_y(dimension)
circle x-4, y-4, x+4, y+4
}
return
|