import java.applet.*; import java.awt.*; public class Sky extends Applet implements Runnable { private Thread thread = null; private Color colors[]; private Image buffer; private Graphics gContext; int maxpos = 0; int red = 0; int green = 0; int blue = 0; int linefactor = 4; Image pic; boolean wait = true; boolean redbo = true; boolean bluebo = false; boolean greenbo = false; boolean rise = true; public void init(){ String parm; colors = new Color[getSize().height/linefactor]; MediaTracker tracker = new MediaTracker(this); pic = getImage(getDocumentBase(), getParameter("pic")); tracker.addImage(pic, 0); try { tracker.waitForID(0); } catch(Exception e) {}; for(maxpos = 0; maxpos<(getSize().height/linefactor)-1 ; maxpos++){ colors[maxpos]=new Color(0,0,0); } maxpos = getSize().height; buffer = createImage(getSize().width,getSize().height); gContext = buffer.getGraphics(); gContext.setFont(new Font("Arial",Font.BOLD,24)); } public void update(Graphics g){ if (pic == null) return; wait = true; for(maxpos = 1; maxpos < (getSize().height/linefactor)-1 ; maxpos++) { colors[maxpos-1]=colors[maxpos]; gContext.setColor(colors[maxpos]); gContext.fillRect(0,(maxpos-1)*linefactor ,getSize().width,((maxpos-1)*linefactor)+linefactor); } createcolorFade(); colors[maxpos-1]=new Color(red,green,blue); gContext.drawImage(pic,0,0,this); gContext.setColor(new Color(red,green,blue)); wait = false; paint(g); } public void paint(Graphics g){ if(!wait){ if (buffer!= null){ g.drawImage(buffer, 0, 0, null); } } } public void start(){ if (thread == null){ thread = new Thread(this); thread.start(); } } public void stop(){ if (thread != null) { thread.stop(); thread = null; } } public void run(){ while (true){ try{ repaint(); Thread.sleep(100); }catch (InterruptedException e){ stop(); } } } public void createcolorFade(){ if( rise){ if( redbo == true ){ red += 15; if ( red == 255){ redbo = false; greenbo = true; } } if( greenbo == true ){ green += 15; if ( green == 255){ greenbo = false; bluebo = true; } } if( bluebo == true ){ blue += 15; if ( blue == 255){ bluebo = false; greenbo = true; rise = false; } } }else{ if( greenbo == true ){ green -= 15; if ( green == 0){ greenbo = false; redbo = true; } } if( redbo == true ){ red -= 15; if ( red == 0){ redbo = false; bluebo = true; } } if( bluebo == true ){ blue -= 15; if ( blue == 0){ bluebo = false; redbo = true; rise = true; } } } } }