/* by Peter Wirbelauer */
include "sw.inc"
Window 320,320,1
Sub Trauma(single im,ii,st)
single fx, fy, i
sys r, g, b, c, x, y
for x=0 to <320
i =1
fy=0
for y=0 to < 320
c=i*(1+cos(fx))+i*(1+cos(fy))
SetPixel x,320-y,c
i=i*im+ii
fy +=st
next
fx +=st
next
End Sub
while Key(27)=0
single m,n
m=1
n=1
for i=1 to 120
Trauma (m,n, .01)
n +=111
Redraw
next
m=1.0100
n=.4
for i=1 to 120
Trauma (m,n, .03)
m +=.0005
Redraw
next
wend
Quit()
for y=0 to < 320
Art of programming :D
for y=0 to 319
include "sw.inc"
Window 640,480,1
Sub MultiCircle(sys xc,yc,r, single m, sys color)
sys iter=2*pi*r : single theta : sys x, y
for i=0 to i <= iter
theta = m*pi*i / iter
x = xc + r * cos(theta)
y = yc + r * sin(theta)
Line xc, yc, x, y ,4, color
next
End Sub
Cls RGB(0,0,255)
MultiCircle 300,240,140, 1.5,RGB(255,230,155)
MultiCircle 300,240,100, 1.2,RGB(55,30,155)
MultiCircle 300,240, 40, 0.5,RGB(55,130,55)
MultiCircle 300,240, 10, 2.0,RGB(255,130,55)
MultiCircle 300,240,200,32.5,RGB(255,130,55)
MultiCircle 600, 50, 25, 2.0,RGB(255,0,0)
MultiCircle 600,420, 25,62.5,RGB(0,255,0)
MultiCircle 60, 50, 25, 9.5,RGB(255,0,0)
MultiCircle 60, 420, 25, 1.0,RGB(0,255,0)
WaitKey
Quit
Amazing, you got it. What about the speed?
Runs the Animation fluidly?
Looks cool, trainee.
include "sw.inc"
Window 640, 480, 1
sys x, y, z, single x1, y1, x2, y2, winkel2
single xMagnet[768]
single yMagnet[768]
single wMagnet[768]
single sinus[360]
single cosin[360]
Function Distance(single x1,y1,x2,y2) as single
single dx, dy
dx = x1-x2
dy = y1-y2
Return sqr(dx*dx+dy*dy)
End Function
Function xMove(single x,winkel,speed) as single
single x2
x2 = x + cosin[winkel]*speed
return x2
End Function
Function yMove(single y,winkel,speed) as single
single y2
y2 = y + sinus[winkel]*speed
return y2
End Function
Function winkel(single x1,y1,x2,y2) as single
single xhypo, yhypo, abstand, xwinkel
xhypo = x2 - x1
yhypo = y2 - y1
abstand = Distance x1,y1,x2,y2
xwinkel = abs(acos(xhypo/abstand))
if sgn(xhypo) = -1 and sgn(yhypo) = -1 then xwinkel =180 + (180 - xwinkel)
if sgn(xhypo) = 1 and sgn(yhypo) = -1 then xwinkel =270 + ( 90 - xwinkel)
return xwinkel
End Function
for x=0 to 31
for y=0 to 23
z=y*32+x
xMagnet[z] = x*20
yMagnet[z] = y*20
next
next
for x=0 to 360
sinus[x] = sin(x)
cosin[x] = cos(x)
next
while Key(27)=0
Cls RGB(205,205,205)
for x=1 to 31
for y=1 to 23
z=y*32+x
wMagnet[z] = winkel(xMagnet[z],yMagnet[z],xMouse,yMouse)
x1 = xMove(xMagnet[z], wMagnet[z], 8)
y1 = yMove(yMagnet[z], wMagnet[z], 8)
winkel2 = wMagnet[z] - 180
if winkel2 < 0 then winkel2 =360 + winkel2
x2 = xMove(xMagnet[z], winkel2, 8)
y2 = yMove(yMagnet[z], winkel2, 8)
Line x1, y1, xMagnet[z], yMagnet[z],4, RGB(255,0,0)
Line x2, y2, xMagnet[z], yMagnet[z],4, RGB(0,0,255)
next
next
Sync()
wend
Quit()
DECLARE SUB DLLC_File ALIAS "dllfile" LIB "DLLC"
DECLARE SUB DLLC_Proc ALIAS "dllproc" LIB "DLLC"
DECLARE SUB DLLC_Call ALIAS "dllcall" LIB "DLLC"
sw = DLLC_File("sw.dll")
Window = DLLC_Proc(sw, "Window i = (i width, i height, i mode)")
SetCaption = DLLC_Proc(sw, "SetCaption i = (c*capText)")
DrawLine = DLLC_Proc(sw, "Line i = (i xPos, i yPos, i a, i b, i thickness, i color)")
xMouse = DLLC_Proc(sw, "xMouse i = ( )")
yMouse = DLLC_Proc(sw, "yMouse i = ( )")
Key = DLLC_Proc(sw, "Key i = (i mKey)")
Cls = DLLC_Proc(sw, "Cls i = (i color)")
RGB = DLLC_Proc(sw, "RGB i = (i rValue, i gValue, i bValue)")
Sync = DLLC_Proc(sw, "Sync ( )")
Quit = DLLC_Proc( sw,"Quit i = ( )")
DLLC_Call(Window, 640, 480, 1)
DLLC_Call(SetCaption,"ScriptBasic")
FUNCTION Distance(x1,y1,x2,y2)
LOCAL dx, dy
dx = x1-x2
dy = y1-y2
Distance = SQR(dx*dx+dy*dy)
END FUNCTION
FUNCTION xMove(x, winkel, speed)
LOCAL x2
x2 = x + cosin[winkel] * speed
xMove = x2
END FUNCTION
FUNCTION yMove(y,winkel,speed)
LOCAL y2
y2 = y + sinus[winkel] * speed
yMove = y2
END FUNCTION
FUNCTION winkel(x1, y1, x2, y2)
LOCAL xhypo, yhypo, abstand, xwinkel
xhypo = x2 - x1
yhypo = y2 - y1
abstand = Distance(x1, y1, x2, y2)
xwinkel = ABS(ACOS(xhypo / abstand))
IF SGN(xhypo) = -1 AND SGN(yhypo) = -1 THEN xwinkel = 180 + (180 - xwinkel)
IF SGN(xhypo) = 1 AND SGN(yhypo) = -1 THEN xwinkel = 270 + (90 - xwinkel)
winkel = xwinkel
END FUNCTION
FOR x = 0 TO 31
FOR y = 0 TO 23
z = y * 32 + x
xMagnet[z] = x * 20
yMagnet[z] = y * 20
NEXT
NEXT
FOR x = 0 TO 360
sinus[x] = SIN(x)
cosin[x] = COS(x)
NEXT
WHILE DLLC_Call(Key,27) = 0
DLLC_Call(Cls, DLLC_Call(RGB,205,205,205))
FOR x = 1 TO 31
FOR y = 1 TO 23
z = y * 32 + x
wMagnet[z] = winkel(xMagnet[z], yMagnet[z], DLLC_Call(xMouse), DLLC_Call(yMouse))
x1 = xMove(xMagnet[z], wMagnet[z], 8)
y1 = yMove(yMagnet[z], wMagnet[z], 8)
winkel2 = wMagnet[z] - 180
IF winkel2 < 0 THEN winkel2 = 360 + winkel2
x2 = xMove(xMagnet[z], winkel2, 8)
y2 = yMove(yMagnet[z], winkel2, 8)
DLLC_Call(DrawLine, x1, y1, xMagnet[z], yMagnet[z], 4, DLLC_Call(RGB, 255, 0, 0))
DLLC_Call(DrawLine, x2, y2, xMagnet[z], yMagnet[z], 4, DLLC_Call(RGB, 0, 0, 255))
NEXT
NEXT
DLLC_Call(Sync)
WEND
DLLC_Call(Quit)