Bennu Game Development

English Forums => Resources => Topic started by: cmunoz on August 28, 2016, 03:23:18 AM

Title: Process draws antialiased fcircle!
Post by: cmunoz on August 28, 2016, 03:23:18 AM
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
Title: Re:Process draws antialiased fcircle!
Post by: SplinterGU on August 28, 2016, 05:19:57 PM
thanks!