Oxygen Basic
Programming => Example Code => Topic started by: Peter on June 03, 2013, 07:48:59 AM
-
Deleted
-
Attached is Peter's original example done in O2.
X
-
I thought I would expand on Peter's code and see where it would take me. Thanks Peter for this cool demo. The repetition of your code with a twist to compensate for the no line width issue paid off. You should give this a try (SB / O2 / ...) as the patterns it creates are rather random.
(http://files.allbasic.info/ScriptBasic/timeline.png)
' Peter's Lifetime
import japi.bas
declare sub dllsecs alias "dllsecs" lib "DLLC"
' j_setdebug(4)
j_start
win = j_frame("Peter's Lifetime")
can = j_canvas(win, 400, 300)
j_pack(win)
j_show(win)
centerX = fix(j_getwidth(can) / 2)
centerY = fix(j_getheight(can) / 2)
totalLines = 20
REPEAT
j_setnamedcolorbg(can, J_WHITE)
For i = -20 to 20
offsetX = cos(dllsecs()*i*(0.25 / totalLines))*100
offsety = sin(dllsecs()*i*(0.25 / totalLines))*100
j_setcolor(can,16,128,200)
j_drawline(can, centerX - offsetX, centerY - offsetY, centerX + offsetX, centerY + offsetY)
offsetX = cos(dllsecs()*i*(0.50 / totalLines))*100
offsety = sin(dllsecs()*i*(0.50 / totalLines))*100
j_setcolor(can,200,128,16)
j_drawline(can, centerX - offsetX, centerY - offsetY, centerX + offsetX, centerY + offsetY)
Next
j_sleep(250)
UNTIL 0
j_quit
-
Here is the O2 version of my modification to Peters program. The ZIP contains everything you need to run and compile the example. I was fortunate to be able to get a screen shot that looked like the SB JAPI example.
(http://files.allbasic.info/O2/lifetime.png)
#include "sw.inc"
! timeGetTime Lib "winmm.dll" () As Long
Window 400,300,1
sys centerX = GetWidth () /2
sys centerY = GetHeight() /2
sys totalLines=20, i, j
single offsetX, offsetY
while Key(27)=0
Cls sw_white
For i= -totalLines to totalLines
offsetX = cos(timeGetTime()*i*(0.25 / totalLines))*100
offsety = sin(timeGetTime()*i*(0.25 / totalLines))*100
Line centerX-offsetX,centerY-offsetY,centerX+offsetX,centerY+offsetY,1,RGB(16,128,200)
offsetX = cos(timeGetTime()*i*(0.50 / totalLines))*100
offsety = sin(timeGetTime()*i*(0.50 / totalLines))*100
Line centerX-offsetX,centerY-offsetY,centerX+offsetX,centerY+offsetY,1,RGB(200,128,16)
Next
Sync
SetFps 8
wend
CloseWindow
X