Hello, i'm trying to experiment with image manipulation and I'm trying to get the effect of an image dematerializing by randomly setting each individual pixel transparent until the entire image is transparent. It works but it takes way too long for the entire image to become completely transparent as it only checks one pixel at a time. Here is the code I have been using. Are there any recommendations on what I should change/add?
public void dematerialize() { int w = getImage().getWidth(); int h = getImage().getHeight(); int randW= Greenfoot.getRandomNumber(w); int randH=Greenfoot.getRandomNumber(h); Color transparent = new Color(255,255,255,0); if(getImage().getColorAt(randW,randH)!=transparent) getImage().setColorAt(randW, randH, transparent); }