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
|
' $Id$
Import noddybox.algorithm
Const SCRW=800
Const SCRH=600
SetGraphicsDriver GLMax2DDriver()
Graphics SCRW,SCRH,32,60' Or HARDSYNC
HideMouse()
Local x1:Int=200
Local x2:Int=600
Local y1:Int=500
Local y2:Int=100
Local yi:Int=-1
Local xi:Int=1
While Not KeyHit(KEY_ESCAPE)
Cls
Rem
Local l:TList=DoLine(Rand(0,SCRW),Rand(0,SCRH),Rand(0,SCRW),Rand(0,SCRH))
For Local p:TAlgoPoint=EachIn l
SetColor(Rand(100,255),Rand(100,255),Rand(100,255))
Plot(p.x,p.y)
Next
EndRem
Local pa:TAlgoPoint[]=DoCircle(Rand(0,SCRW),Rand(0,SCRH),Rand(100,200))
For Local f:Int=0 To 359
Local nf:Int=(f+1) Mod 360
SetColor(Rand(100,255),Rand(100,255),Rand(100,255))
DrawLine(pa[f].x,pa[f].y,pa[nf].x,pa[nf].y)
Next
SetColor(255,0,0)
DrawLine(x1,y1,x2,y2)
'x1:+xi
'x2:-xi
'y1:+yi
'y2:-yi
If x1=200 Or x1=600
xi=-xi
EndIf
If y1=100 Or y1=500
yi=-yi
EndIf
SetColor(0,0,255)
DrawOval(MouseX()-10,MouseY()-10,20,20)
SetColor(255,255,255)
Local pl:TAlgoPoint3D[]=CircleIntersects(x1,y1,0,x2,y2,0,MouseX(),MouseY(),0,10)
Local y:Int=50
For Local p:TAlgoPoint3D=EachIn pl
DrawText(p.x+","+p.y,0,y)
y:+10
Plot(p.x,p.y)
Next
Flip
FlushMem
Wend
EndGraphics
End
|