k4st
public text v1 · immutablepublic Picture circleNegate(int centerx, int centery, int radius)
{
int x, y;
Pixel pixelObj;
for(y=centery-radius; y<=centery+radius; y++)
{
for(x = centerx-radius; x <= centerx+radius; x++)
{
if(Math.sqrt((int)((x-centerx)*(x-centerx) - (y-centery)*(y-centery))) <= radius)
{
pixelObj= this.getPixel(x,y);
pixelObj.setRed(255-pixelObj.getRed());
pixelObj.setBlue(255-pixelObj.getBlue());
pixelObj.setGreen(255-pixelObj.getGreen());
}
}
}
return this;
}