RawDrawUnfilledCircle (SOLVED)

Started by Akumayo, Sat 06/05/2006 05:12:31

Previous topic - Next topic

Akumayo

Is it possible, even with a workaround, to make AGS draw an unfilled circle, rather than the filled ones it draws currently.Ã,  The ability of the engine to do this is crucial to the user-end of my game...

-Thanks in advance, Akumayo
"Power is not a means - it is an end."

Kweepa

#1
Of course, using the RawDrawLine function.

[EDIT] Heh, I started writing it with radians, but then changed it half way because I was sure CJ had "dumbed down" the functions to take degrees :) Silly me. Code erased because Wretched's is obviously better (and working!).
Still waiting for Purity of the Surf II

Wretched

#2
 Maths.Sin() and cos() use radians. Also you could get a duplicate arc due to floating point precision with < 360.0

Code: ags

function RawDrawUnfilledCircle(int x, int y, int radius)
{
Ã,  float farcs;
Ã,  
Ã,  float fradius=IntToFloat(radius);
Ã,  float t0;
Ã,  float t1;

Ã,  farcs=2.0*Maths.Pi*fradius/10.0; //Try to keep big circles smooth
Ã,  farcs=IntToFloat(FloatToInt(farcs));
Ã,  if (farcs<18.0) 
Ã,  {
Ã,  Ã,  Ã, farcs=18.0;
Ã,  }
Ã,  
Ã,  
Ã,  float a=0.0;
Ã,  while (a<farcs)
Ã,  {
Ã,  Ã,  t0=(a)*Maths.Pi*2.0/farcs;
Ã,  Ã,  t1=(a+1.0)*Maths.Pi*2.0/farcs;
Ã,  Ã,  
Ã,  Ã,  RawDrawLine(x+FloatToInt(fradius*Maths.Cos(t0)), 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  y+FloatToInt(fradius*Maths.Sin(t0)), 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  x+FloatToInt(fradius*Maths.Cos(t1)), 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  y+FloatToInt(fradius*Maths.Sin(t1)) ); 
Ã,  Ã,  a=a+1.0;
Ã,  }

}


Akumayo

Wow Wretched!  Thanks alot.  Now I know how to go about scripting something like this!
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk