Draw pixel and alpha channel - Printable Version +- NaaLaa (https://www.naalaa.com/forum) +-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html) +--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html) +--- Thread: Draw pixel and alpha channel (/thread-70.html) Pages: 1 2 Draw pixel and alpha channel - Tomaaz - 02-07-2024 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. RE: Draw pixel and alpha channel - johnno56 - 02-07-2024 (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 RE: Draw pixel and alpha channel - Tomaaz - 02-07-2024 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). RE: Draw pixel and alpha channel - johnno56 - 02-07-2024 ... ah, but it is still a very nice 'conversion'... No change from my previous. 'Nicely done!'... RE: Draw pixel and alpha channel - 1micha.elok - 02-07-2024 (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 RE: Draw pixel and alpha channel - Marcus - 02-08-2024 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 RE: Draw pixel and alpha channel - Marcus - 02-08-2024 I can confirm that 'draw pixel' doesn't seem to care about the alpha channel. How weird. I'll fix that RE: Draw pixel and alpha channel - Tomaaz - 02-08-2024 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. RE: Draw pixel and alpha channel - aurel - 02-08-2024 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``` RE: Draw pixel and alpha channel - johnno56 - 02-09-2024 Cool... Nice colours!