アットウィキロゴ

xxip

import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
import java.awt.image.*;

class pro extends Frame implements Runnable{

Frame f;
Thread th;
int num;
PixelGrabber pg;
Color col;
Image img;
int w=847;
int h=899;
int pix[]=new int[w*h];
int red,green,blue;
int memor[]=new int[w*h];
int memog[]=new int[w*h];
int memob[]=new int[w*h];

public static void main(String[] args){
Frame f=new pro();
f.setSize(1000,1000);
f.setBackground(Color.yellow);
f.show();
}

pro() {
addWindowListener(new stopwin());
img = createImage(w,h);
img = Toolkit.getDefaultToolkit().getImage("king.jpg");
pg = new PixelGrabber(img,0,0,w,h,pix,0,w);
try{pg.grabPixels();}catch(InterruptedException ie){}
for(int i=0;i<w*h;i++){
int p = pix[i];
col=new Color(pix[i]);
red=col.getRed();
green=col.getGreen();
blue=col.getBlue();
memor[i]=red;
memog[i]=green;
memob[i]=blue;
}
num=1;
th=new Thread(this);
th.start();
}

class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}

public void paint( Graphics g ) {
int i,mx,nx,z;
int rgb;
int han;
mx=1;
nx=1;
g.setColor(Color.yellow);
g.fillRect(0,0,1000,1000 );
for (i=0;i<w*h;i++){
rgb=(int)(0.6*memor[i]+0.3*memog[i]+0.1*memob[i]);
han=0;
g.setColor(new Color(memor[i],memog[i],memob[i]));
if (rgb<250)g.fillRect(nx+20*num,mx+100+50*num,1,1 );
nx=nx+1;
if (nx>w)mx=mx+1;
if (nx>w)nx=1;
}
num=num+1;
}

public void update(Graphics g) {
paint(g);
}

public void run() {
int i;
for (i=1;i<11;i++){
repaint();
try{th.sleep(1000);} catch(InterruptedException e) { }
}
}

}
最終更新:2010年09月26日 03:14