# NaaLaa

Full Version: Draw pixel and alpha channel
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
(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...

[attachment=68]

Nicely done!

J
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).
... ah, but it is still a very nice 'conversion'... No change from my previous. 'Nicely done!'...
(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 ... I like it
Afaik alpha works 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
I can confirm that 'draw pixel' doesn't seem to care about the alpha channel. How weird. I'll fix that
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.
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```
Cool... Nice colours!
Pages: 1 2