• #### The code is ok..Good

Posted by Legacy on 08/17/2001 12:00am

Originally posted by: James P

Your code is quite ok.But can't you make it more powerful

• #### N-Sided Polygons

Posted by Legacy on 08/16/2001 12:00am

Originally posted by: Craig Moore

I think that it may have been useful to post the fact that you wish to draw n-sided <i>regular</i> polygons, as surely there are scanline rendering algorithsm for drawing polygons already. Also, it may have been useful to post an algorithm for scanlining solid polygons, as they are more useful imho.

• #### Here are some thoughts for you...

Posted by Legacy on 08/15/2001 12:00am

Originally posted by: John

```A better approach might be to have a general n-sided
polygon drawing function, such as:

void DrawPoly( double x, double y, double Radius, double Angle,
int Sides, COLORREF Color )
{
// set the pen and fill colors as needed
// ...
// ...

double Delta = (2*3.14159265) / Sides;

for ( int i = 0; i < Sides; i++ )
{
double nx, ny;

nx = x + ( Radius * cos( Angle + i * Delta ) );
ny = y + ( Radius * sin( Angle + i * Delta ) );

if ( !i )
MoveTo( (int)(x + Radius), (int)y );
else
LineTo( (int)nx, (int)ny );
}
}

I left out the details of setting pen/brush colors, and I
glossed over the actual drawing stuff, but the idea is to
create the function and call it from inside the OnMouseMove
code.  That way, your code is much cleaner, and you can
create n sided poly's from anywhere without having to
copy/paste all over the place.

Remember, C and C++ allow us to create functions which
should be as reusable as possible.  Less code means easier
debugging and usually more efficient operation.

Good luck!

-John

PS: Editing code in this browser window sucks.  :-)
```

• #### its interesting

Posted by Legacy on 08/14/2001 12:00am

Originally posted by: ambrish

```thats a nice and interesting article.
give a lot of insight.
```

• #### mull's vc code

Posted by Legacy on 08/13/2001 12:00am

Originally posted by: rohil sahgal

i think mayank malik is one of the most talented programmers i've met and this is only a sample of what he can do....i've known him for the last 4 yrs and he's as good a person as he is a programmer!! if anybody out there is looking for a dedicated, talented and brilliant software programmer..look no further for he's ur man :)
ensoi and keep the faith

• #### Code looks good -- although roundoff errors are plenty

Posted by Legacy on 08/13/2001 12:00am

Originally posted by: Charles Vaz

```Try changing the sides to 20 and see noticable effects due to integer rounding errors.

```