import java.applet.*; import java.awt.*; import java.awt.image.*; import java.util.*; public class LaserPic extends Applet{ private Image image; private int x = 25,y = 25; private Random random; private int width,height,w,h,image_size,pixels[]; public void init() { random=new Random(); String imageName=getParameter("Image"); image=getImage(getDocumentBase(),imageName); MediaTracker imageTracker=new MediaTracker(this); imageTracker.addImage(image,0); try { imageTracker.waitForID(0); }catch (InterruptedException e){} } public void start(){ width=getSize().width; height=getSize().height; w=image.getWidth(this); h=image.getHeight(this); x = (width - w)/2; y = (height - h)/2; image_size=w*h; pixels=new int[image_size]; PixelGrabber pg=new PixelGrabber(image,0,0,w,h,pixels,0,w); try { while (!pg.grabPixels()){} } catch (InterruptedException e){} } public void paint(Graphics g) { g.setColor(Color.white); g.fillRect(0,0,getSize().width,getSize().height); drawImage(g,image,x,y); } private void drawImage(Graphics g,Image image,int x,int y){ while(true){ g.setColor(Color.white); g.fillRect(0,0,getSize().width,getSize().height); try { int one_time=w; int S_x=0,S_y=0; S_x=(int)(random.nextFloat()*width); S_y=(int)(random.nextFloat()*height); Laser[] nextlot=new Laser[one_time]; int k=0,l=0; int step=1,start=0; float f=random.nextFloat(); step=(f<0.8)?34759:(f<0.9?1:image_size-1); start=(int)(random.nextFloat()*image_size); f=random.nextFloat(); start=(f<0.5)?image_size:0; int sofar=0; for (k=start;l