CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 20

Threaded View

  1. #12
    Join Date
    Oct 2019
    Posts
    5

    Re: Set Sided Polygon in C++

    Code:
    void PixelPlotterForm::DrawPolygon( int Sides, int X, int Y, int R, Color PixelColour )
    {
    	int x = X;
    	int y = Y;
    	int r = R;
    	int sides = Sides;
    
    	float cir = PI * (r * 2);
    
    	float edgelength = cir / sides;
    	float tempsides = 0;
    
    	float angle = 360 / sides;
    
    	while(tempsides < sides)
    	{
          		SetViewportPixel(x + r, y + r, PixelColour);
    		r = r + angle;
    		tempsides++;
    	}
    }
    Last edited by VictorN; October 17th, 2019 at 04:24 AM. Reason: added code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured