|
Post by johnno56 on Jan 27, 2021 15:11:15 GMT -6
Aurel, Here is my attempt. xmax = 500 ymax = 305 title$ = "Rainbow by Aurel"
WindowOpen(1,title$,windowpos_centered,windowpos_centered,xmax,ymax,0) CanvasOpen(1,xmax,ymax,0,0,xmax,ymax,0) ClearCanvas
fnt14 = 1: loadFont(1,"arial.ttf", 14) font(fnt14)
setColor(rgb(0, 0, 100)) RectFill(0, 0, xmax - 1, ymax - 1)
'abstract rainbow by PeterW from o2
m= -1.57 : x1 = 1 : y1 = 301 : q= 0.00101 gx = 0.15: gy = 0.3 : s = 1 'wcolor 0,0,0 :bcolor 0,0,100
setColor(rgb(150,200,220)) DrawText("Rainbow by Peter Wirbelauer", 310, 10)
While s < 3108 m = m + q x1 = x1 + gx * cos(m) y1 = y1 + gy * sin(m) x2 = (x1 + 150)/2 : y2 = (y1 + 300)/2 x3 = (x1 + x2) /2 : y3 = (y1 + y2) /2 x4 = (x2 + 150)/2 : y4 = (y2 + 300)/2 x5 = (x1 + x3) /2 : y5 = (y1 + y3) /2 x6 = (x2 + x3) /2 : y6 = (y2 + y3) /2 x7 = (x2 + x4) /2 : y7 = (y2 + y4) /2 x8 = (x4 + 150)/2 : y8 = (y4 + 300)/2 setColor(rgb(255, 0, 0)): line(x1, y1, x5, y5) setColor(rgb(255, 102, 0)): line(x5, y5, x3, y3) setColor(rgb(255, 255, 0)): line(x3, y3, x6, y6) setColor(rgb(0, 255, 0)): line(x6, y6, x2, y2) setColor(rgb(0, 0, 255)): line(x2, y2, x7, y7) setColor(rgb(0, 0, 128)): line(x7, y7, x4, y4) setColor(rgb(128, 0, 128)): line(x4, y4, x8, y8) s = s + 1
update(): ' - add "'" for immediate image Wend setColor(rgb(150,200,220)) DrawText("Press ANY key to EXIT", 310, 280) update() waitkey Comment out the "update" within the loop for an immediate image. J Attachments:arial.ttf (358.5 KB)
|
|
|
Post by johnno56 on Jan 28, 2021 7:59:51 GMT -6
I may be wrong, but the inner loop 'update' updates or refreshes the display. Doing that during each cycle of the while...wend loop will slow things down. Likewise, if the inner update is omitted, then there is little to no delay in refreshing the screen.
On my machine both 'slow' and 'quick' ran ok and waited for a keypress. If yours 'exits' without waiting, then my guess would be that, when you run (or F5) the rainbow is drawn so quickly that the F5 keypress is still registering...? Just a guess. Maybe n00b would be able to answer? that one?
|
|
|
Post by n00b on Jan 28, 2021 9:43:56 GMT -6
johnno56 You can speed this up by drawing in a window with vsync disabled. Just change your WindowOpen() to this: WindowOpen(1,title$,windowpos_centered,windowpos_centered,xmax,ymax,4) aurel Can you post the code that was causing the error?
|
|
|
Post by johnno56 on Jan 28, 2021 13:11:03 GMT -6
Cool. That certainly sped things up quite a bit. Reduced from about seven seconds to maybe one... Running it without the 'internal' update... Well... Best not blink... lol
|
|
|
Post by n00b on Jan 29, 2021 14:48:35 GMT -6
it seems to work for me
|
|
|
Post by johnno56 on Jan 29, 2021 17:22:11 GMT -6
Aurel,
I cut and paste the listing into my Linux machine and it worked fine.
If yours 'just closes' after the drawing of the rainbow, may I suggest that, you change the waitkey to something else... maybe waitkey(32) or waitkey(27)
It could be a hardware type issue... maybe the keyboard buffer is not 'clearing' fast enough and is still registering the initial keypress when the program started. Seeing the statement waitkey is waiting for 'any' key then that may be an explanation. Changing the waitkey to either 32 (space) or 27 (escape) should force the hardware to 'wait' for a specific key. Just a guess...
|
|
|
micro(A)
Feb 2, 2021 17:23:55 GMT -6
via mobile
Post by Tomaaz on Feb 2, 2021 17:23:55 GMT -6
|
|
|
Post by Tomaaz on Feb 2, 2021 17:33:24 GMT -6
|
|
|
micro(A)
Feb 3, 2021 7:07:01 GMT -6
via mobile
Post by Tomaaz on Feb 3, 2021 7:07:01 GMT -6
Aurel, is that your new hobby? Editing all your posts as soon as someone disagrees with you?
|
|
|
Post by johnno56 on Feb 7, 2021 13:38:40 GMT -6
Aurel,
Challenge accepted... One RCBasic version (hopefully)...
xmax = 640 ymax = 480 title$ = "Butterfly Effect - Aurel 2021"
' Converted from original micro(A)
WindowOpen(1,title$,0,0,xmax,ymax,0) CanvasOpen(1,xmax,ymax,0,0,xmax,ymax,0)
Dim x: Dim y: Dim i: Dim a: Dim turn Dim cx: Dim cy: Dim cr
while turn < 1000 clearcanvas i = 0 while i < 120 setColor(rgb(rand(255),rand(255),rand(255))) x = sin(i + a) * 50 - cos(i - a) * i y = cos(i + a) * 50 + sin(i - a) * i cx = x + 320 cy = y + 240 cr = sin(i) * 5 circlefill(cx,cy,cr) i = i + 0.8 if key(27) = 1 then wait(1000) end end if wend a = a + 0.128 if a > 360 then a = -a end if turn = turn + 0.5 update() wend
waitkey
|
|
|
Post by aurelX on Feb 8, 2021 16:26:30 GMT -6
|
|
|
Post by aurelX on Feb 9, 2021 16:24:22 GMT -6
mr Charles macro FindPrimes(p) finit double n=1 sys c,k do n+=2 if c>=max then exit do ' 'IS IT DIVISIBLE BE ANY PREVIOUS PRIME ' for k=1 to c if frac(n/p[k])=0 then exit for next ' if k>c then c++ p[c]=n end if end do end macro
|
|
|
Post by n00b on Feb 10, 2021 20:31:14 GMT -6
I tried out the examples. The syntax is simple and clean. It was pretty easy to pick up on the language from just looking at the examples.
|
|
|
micro(A)
Feb 11, 2021 3:03:08 GMT -6
via mobile
Post by Tomaazz on Feb 11, 2021 3:03:08 GMT -6
Aurel, I haven't tried your code, but from looking at it - shouldn't it be "if k = c"?
|
|
|
Post by johnno56 on Mar 10, 2021 18:08:05 GMT -6
Just curious... You wouldn't be left-handed by any chance?
|
|