Color waves bplus Junior Member Posts: 34 Threads: 8 Joined: Jul 2018 Reputation: 0 07-18-2018, 03:31 PM (This post was last modified: 07-18-2018, 03:45 PM by bplus.) Hi Gloomshroud, Sorry about the math, I was trying to get going again with Naalaa and picked what I thought should be something easy and be eye candy! Imagine a grid of points. Imagine a string tied to each point. Imagine a ball swinging around at the end of the string. Now imagine the swinging balls synchronized so they create a wave pattern down each row, a sine or cosine wave. Now imagine all the rows of swinging balls, waves, also synchronized. You get a wavy surface. I can dig up a cleaner, maybe more understandable coding if you are interested. You would be able to see the points, strings and balls rotating at the end of the strings. It's pretty cool too as you can pattern the colors like pixels in text to produce a wavy message. Hi Johnno and Marcus, Today I spent morning testing circle fill routines against Draw Ellipse. On my machine, the code I used for drawing a filled circle in wavy takes about half the time as draw ellipse but the "circles" are more like rounded diamonds. I did find a couple of comparable times to draw ellipse time and one might slightly edge it out in time. It is the gold standard used at QB64 but the difference is so slight it does not justify carrying the extra code. My test loop ran radii from 255 to 1 varying the color, here is the code with results in comments. I am interested in what results Linux produces.   Filled circle tests.zip (Size: 1.66 KB / Downloads: 3) OK I tested download of zip and it works perfectly. You will have to comment out the one line _QBfcirc and uncomment draw ellipse with true for filled version, to compare times. b = b + geberation johnno56 Member Posts: 99 Threads: 5 Joined: Feb 2018 Reputation: 2 07-18-2018, 09:30 PM Ok. Ran each method several times. Draw circle avg: 45ms Draw ellipse avg: 15ms In both cases the images were produced that fast I could not see it being drawn. Cool. bplus Junior Member Posts: 34 Threads: 8 Joined: Jul 2018 Reputation: 0 07-18-2018, 11:47 PM (This post was last modified: 07-18-2018, 11:58 PM by bplus.) (07-18-2018, 09:30 PM)johnno56 Wrote: Ok. Ran each method several times. Draw circle avg: 45ms Draw ellipse avg: 15ms In both cases the images were produced that fast I could not see it being drawn. Cool. You definitely have different results on Linux! Code:```' Much better wavy.txt ' written for Naalaa 6 by bplus 2018-07-18 radians constant: wW 512 wH 512 visible: pi# = acos#(-1.0) hidden: set window 100, 20, wW, wH wln "B+ " wln "..." p[21][ 21] for y = 0 to 16    for x = 0 to 16        if pixeli(x, y) <> pixeli(0, 10) then p[x + 3][ y + 3] = 1    next next 'check array, good! 'for y = 0 to 19 '    for x = 0 to 19 '        if p[x][y] = 1 '            set color 0, 0, 255 '            draw rect 100 + x, 100 + y, 1, 1 '        endif '    next 'next 'wait keydown set redraw off r = 1 ; phase# = 0.0; loopCount = 0; d = 1 while 1    set color 0, 0, 0    draw rect 0, 0, wW, wH, true    loopCount = loopCount + 1    if loopCount = 10        loopCount = 0        r = r + d        if r > 15 or r < 2 then d = d * -1    endif    for y = 1 to 20        for x = 1 to 20            'this syncs all the string angles from the grid points            phase# = phase# + pi# / 40.0            ' Sorry the following is still pretty hairy looking: 18.0 = 360 / 20 ie the circle divided into 20 even sections.            ' The following calculates the other end of all the strings which is the origin of the swinging balls (xs, ys).            ' The points have a distance of 20 and the strings are also 20 pixels long.            ' The 40 is an offset to provide a margin for the point grid.            xs = 40 + 20 * x + int(20.0 * cos#(pi# / 180.0 * (phase# + (float(x) + float(y)) * 18.0)))            ys = 40 + 20 * y + int(20.0 * sin#(pi# / 180.0 * (phase# + (float(x) + float(y)) * 18.0)))            set color 255, 255, 255            draw line 40 + 20 * x, 40 + 20 * y, xs, ys            if p[x][y]                set color 0, 0, 255            else                set color 255, 255, 255            endif            draw ellipse xs, ys, r, r, true        next    next    redraw    wait 100 wend``` OK that code copy / pasted fine from forum to Naalaa editor (after I deleted the characters in the first lines to get them colored in Naalaa). b = b + geberation johnno56 Member Posts: 99 Threads: 5 Joined: Feb 2018 Reputation: 2 07-19-2018, 12:06 AM What's a "Bx"? Nah. Kidding. Much faster... J ps: What 'characters'? bplus Junior Member Posts: 34 Threads: 8 Joined: Jul 2018 Reputation: 0 07-19-2018, 12:13 AM (07-19-2018, 12:06 AM)johnno56 Wrote: What's a "Bx"? Nah. Kidding. Much faster... J ps: What 'characters'? Here is a link to a screen shot (if you are a member of Retrogamecoding): http://retrogamecoding.org/board/index.php?topic=668.0  The code copy / pasted into Naalaa editor is all still Black and White and there is an extra blank line at the top, it does not run and complains about characters at start of program (the blank line). So I deleted the blank line and the start of the next line so that the color comes back to those commented lines. Then it runs fine! b = b + geberation johnno56 Member Posts: 99 Threads: 5 Joined: Feb 2018 Reputation: 2 07-19-2018, 02:47 AM Thanks for the link.. and yes... I am a member... My mistake... was not looking for a blank line... I was looking for characters... :-? « Next Oldest | Next Newest »