Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Twirly Whirly Math Stuff
#1
Code: (Select All)
DefLng A-Z
Screen _NewImage(640, 480, 32)
Dim C(-1 To 0): C(-1) = &HFFFF0000: C(0) = &HFF0000FF

Do
variance = variance + 1
If variance > 640 Then variance = 0
Cls

For i = 0 To 8
k = Not k
x = 25 * Sin(_D2R(30 * i)) + variance
y = 25 * Cos(_D2R(30 * i)) + 50
Circle (x, y), 25, C(k)
Paint (x, y), C(k)
Next

h = _NewImage(50, 100, 32)
_PutImage , 0, h, (variance, 0)-(100, 100)
f = _NewImage(100, 100, 32)
_Dest f
D h, 50, 0, 0, 1: D h, 0, 0, 180, 4
_Dest 0

Cls
a = 0
Do
a = a + 3
For y = -50 To 530 Step 82
Z = Not Z
dir = 1: If Z Then dir = -1
For x = -50 To 690 Step 100
D f, x + Z * 50, y, dir * a, 0
Next x, y
Loop Until a >= 180

Loop

Sub D (Im, x, y, a, m)
Dim px(3), py(3)
w = _Width(Im) - 1: h = 99
Select Case m
Case 0: px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2: px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
Case 1: px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0: px(1) = 0: py(1) = h: px(2) = w: py(2) = h
Case 4: px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h: px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
End Select
s! = Sin(_D2R(a)): c! = Cos(_D2R(a))
For i = 0 To 3
x2 = (px(i) * c! + s! * py(i)) + x: y2 = (py(i) * c! - px(i) * s!) + y
px(i) = x2: py(i) = y2
Next
_MapTriangle (0, 0)-(0, h)-(w, h), Im To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MapTriangle (0, 0)-(w, 0)-(w, h), Im To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub

Code: (Select All)
Screen _NewImage(600, 600, 32)
Do: _Limit 30: Loop
Sub drawPattern (a, s, c As _Byte, N)
If s < 0.001 Then Exit Sub
If c = 1 Then _glColor3f 1, 1, 1 Else _glColor3f 0, 0, 0
_glBegin _GL_POLYGON
For i = a To _Pi(2) + a Step _Pi(2 / N): _glVertex2f s * Cos(i), s * Sin(i): Next
_glEnd
If c = 1 Then drawPattern a + 0.1, s - 0.01, 0, N Else drawPattern a + 0.1, s - 0.01, 1, N
End Sub
Sub _GL ()
Static c
drawPattern c, 1.5, 1, 8
c = c + 0.01
End Sub

Code: (Select All)
Screen _NewImage(600, 600, 32)
Do: _Limit 30: Loop
Sub drawPattern (a, s, c As _Byte, N)
If s < 0.001 Then Exit Sub
If c = 1 Then _glColor3f 1, 1, 1 Else _glColor3f Rnd, Rnd, Rnd
_glBegin _GL_POLYGON
For i = a To _Pi(2) + a Step _Pi(2 / N): _glVertex2f s * Cos(i), s * Sin(i): Next
_glEnd
If c = 1 Then drawPattern a + 0.1, s - 0.01, 0, N Else drawPattern a + 0.1, s - 0.01, 1, N
End Sub
Sub _GL ()
Static c
drawPattern c, 2, 1, 8
c = c + 0.01
End Sub
Reply


Messages In This Thread
Twirly Whirly Math Stuff - by SMcNeill - 10-17-2024, 08:46 PM
RE: Twirly Whirly Math Stuff - by bplus - 10-17-2024, 08:54 PM
RE: Twirly Whirly Math Stuff - by SMcNeill - 10-17-2024, 09:16 PM



Users browsing this thread: 1 Guest(s)