Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Draw pixel and alpha channel
#1
Here is the Bubble Universe example. It seems that alpha element doesn't affect drawing single pixels:

Code:
set window "Bubble Universe", 512, 512
r = 6.283185307179586 / 235
mw = 512
mh = 512
hw = mw / 2
hh = mh / 2
x = 0
v = 0
u = 0
t = 0
k = rnd(190) + 64
set redraw 0
while 1
    set color 0, 0, 0, 255
    draw rect 0, 0, 512, 512, 1
    for i = 0 to 255
        for j= 0 to 255
            u = sin(i + v) + sin(r * i + x)
            v = cos(i + v) + cos(r * i + x)
            x = u + t
            set color i, j, 255 - i, k
            draw pixel int(hw + u * hw * 0.4), int(hh + v * hh * 0.4)
        next
    next
    redraw
    t = t + 0.01
    k = rnd(190) + 64
wend
 
Is this a bug? I've tried draw pixel, set pixel and even both.
Reply
#2
(02-07-2024, 05:50 PM)Tomaaz Wrote: Here is the Bubble Universe example. It seems that alpha element doesn't affect drawing single pixels:

Code:
set window "Bubble Universe", 512, 512
r = 6.283185307179586 / 235
mw = 512
mh = 512
hw = mw / 2
hh = mh / 2
x = 0
v = 0
u = 0
t = 0
k = rnd(190) + 64
set redraw 0
while 1
    set color 0, 0, 0, 255
    draw rect 0, 0, 512, 512, 1
    for i = 0 to 255
        for j= 0 to 255
            u = sin(i + v) + sin(r * i + x)
            v = cos(i + v) + cos(r * i + x)
            x = u + t
            set color i, j, 255 - i, k
            draw pixel int(hw + u * hw * 0.4), int(hh + v * hh * 0.4)
        next
    next
    redraw
    t = t + 0.01
    k = rnd(190) + 64
wend
 
Is this a bug? I've tried draw pixel, set pixel and even both.

Well, in my opinion, this is one impressive graphics demo... Very cool...

Here is a screen shot of how it looks on my machine...

   

Nicely done!

J
Logic is the beginning of wisdom.
Reply
#3
I should have mentioned that it is not my original idea. I thing it was ZXDunny who posted it on one of the forums. When alpha component is working correctly the whole thing is a bit darker and slightly changing brightness between cycles what gives it even more dynamic look (that was my idea, but seems not to be working in NaaLaa).
Reply
#4
... ah, but it is still a very nice 'conversion'... No change from my previous. 'Nicely done!'... Smile
Logic is the beginning of wisdom.
Reply
#5
(02-07-2024, 05:50 PM)Tomaaz Wrote: Here is the Bubble Universe example. It seems that alpha element doesn't affect drawing single pixels:

...

Bubble Universe is a very beautiful art Big Grin ... I like it Big Grin
Reply
#6
Afaik alpha works Smile I haven't tried the program, but you set k only once. Since you use 'rnd' k will have the exact same value everytime you run the program (if that's what fooling you).

I'll have a look when I get home, could ofcourse be a bug Smile
Reply
#7
I can confirm that 'draw pixel' doesn't seem to care about the alpha channel. How weird. I'll fix that Smile
Reply
#8
Yep. Something is wrong. Rnd is called multiple times (you missed the one just before wend), but I also tried to run it with different constant values and it didn't change the look of the bubble.
Reply
#9
i have this version with little bit different colors

Code:
' Bubble universe
' ---------------
' Paul Dunn posted this code but for SpecBAS in a facebook group. It looked so cool that I had to
' rewrite it in n7.

constant TAU = 6.283185307179586

set window "Bubble universe", 512, 512
set redraw off

n = 200; r = TAU/235
x = 0; y = 0;
v = 0; t = 0;
hw = width(primary)/2; hh = height(primary)/2

while not keydown(KEY_ESCAPE)
    set color 0, 0, 0
    cls
    for i = 0 to n  for j = 0 to n
        u = sin(i + v) + sin(r*i + x)
        v = cos(i + v) + cos(r*i + x)
        x = u + t
        set color i, j, 99
        set pixel hw + u*hw*0.4, hh + v*hh*0.4
    next
    t = t + 0.025
   
    set caret hw, 4
    set color 255, 255, 255
    center "Press esc to exit ..."
   
    fwait 60
    redraw
wend
Reply
#10
Cool... Nice colours!
Logic is the beginning of wisdom.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)