Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

draw circle with fill java

double treshold = 0.8;
for (double y = 0, n = 2.0 * radius; y < n; y++)
{
    for (double x = 0; x < n; x++)
    {
        double deltaX = radius - x;
        double deltaY = radius - y;
      	double distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
      	double color = Math.max(0, Math.min(1, radius - distance));
      
        if(color>treshold){
          	//draw pixel (e.g.: openGL: glVertex2i(x, y))
        }
    }
}
Source by gamedev.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #draw #circle #fill #java
ADD COMMENT
Topic
Name
5+9 =