Autor Tema: Process draws antialiased fcircle!  (Leído 379 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado cmunoz

  • Newbie
  • *
  • Mensajes: 42
  • Karma: 0
  • Sexo: Masculino
    • Ver Perfil
Process draws antialiased fcircle!
« en: Agosto 27, 2016, 07:23:18 pm »
Wasn't sure where to post this, but I thought I'd challenge myself to make a process that will draw anti-aliased fcircles. Here's what I came up with:



import "mod_draw";
import "mod_key";
import "mod_map";
import "mod_proc";
import "mod_video";
import "mod_wm";
import "mod_math";


process Main()
begin
    set_mode(320,240,32);
    set_fps(24,0);
set_title("antialias_circle");
   
   aacircle(80,80,40,0,255,127,22,255);
    aacircle(100,100,50,1,0,127,200,255);
   
    repeat
    frame;
    until (key(_esc)||exit_status)
    let_me_alone();
end


process aacircle(xcenter,ycenter,radius,zz,rr,gg,bb,myalpha) //(x,y,radius,drawing_z,red,green,blue,alpha)
private
myx;
myy;
float dist;
distr;
float rem;
end
begin
   drawing_z(zz);
   from myx=(xcenter-radius) to (xcenter+radius) Step 1;
      from  myy=(ycenter-radius) to (ycenter+radius) Step 1;
         dist=sqrt(pow(xcenter-myx,2)+pow(ycenter-myy,2));
         distr=sqrt(pow(xcenter-myx,2)+pow(ycenter-myy,2));
         rem=dist-distr;
         if(dist<radius || (dist==radius && rem==0.00))
            drawing_color(rgba(rr,gg,bb,myalpha));
            drawing_alpha(myalpha);
            draw_box(myx,myy,myx,myy);
         elseif(dist>=radius && dist<=radius+rem)
            drawing_color(rgba(rr,gg,bb,myalpha*(1-rem)));
            draw_box(myx,myy,myx,myy);
         end
      end
   end
end
« última modificación: Agosto 27, 2016, 07:26:06 pm por cmunoz »
@thistof

Desconectado SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12365
  • Karma: 365
  • Sexo: Masculino
    • Ver Perfil
Re:Process draws antialiased fcircle!
« Respuesta #1 en: Agosto 28, 2016, 09:19:57 am »
thanks!
« última modificación: Agosto 28, 2016, 09:48:14 am por SplinterGU »
Download Lastest BennuGD Release: http://www.bennugd.org/node/2