import java.awt.image.*; import java.awt.*; import java.applet.*; public class Pildiuhtlustus3 extends Applet implements Runnable{ int laius=50; int korgus=50; BufferedImage pilt1=new BufferedImage(laius, korgus, BufferedImage.TYPE_INT_RGB); BufferedImage pilt2=new BufferedImage(laius, korgus, BufferedImage.TYPE_INT_RGB); ConvolveOp co; Graphics2D g1=pilt1.createGraphics(); double x=10, y=10, kx=2*Math.random(), ky=2.5*Math.random(); boolean veel=true; int ooteaeg=10; void liiguta(){ if(x+kx>laius-5)kx=-Math.abs(kx); if(y+ky>korgus-5)ky=-Math.abs(ky); if(x+kx<5)kx=Math.abs(kx); if(y+ky<5)ky=Math.abs(ky); x+=kx; y+=ky; } void samm(){ liiguta(); co.filter(pilt1,pilt2); g1.drawImage(pilt2, 0, 0, this); g1.fillOval((int)x-5, (int)y-5, 10, 10); repaint(); } public void run(){ veel=true; while(veel){ samm(); try{Thread.sleep(ooteaeg);}catch(Exception e){} } } public Pildiuhtlustus3(){ float andmed[]=new float[100]; for(int i=0; i<100;i++)andmed[i]=0.01f; co=new ConvolveOp(new Kernel(10, 10, andmed)); g1.setColor(Color.green); new Thread(this).start(); } public void stop(){ veel=false; } public void paint(Graphics g){ g.drawImage(pilt1, 10, 10, this); } public void update(Graphics g){ paint(g); } public static void main(String argumendid[]){ Frame f=new Frame("Kino"); f.add(new Pildiuhtlustus3()); f.setSize(70, 100); f.setVisible(true); } }