import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
class game0524 extends Frame{
int x0,x1;
int y0,y1;
int trm,trn;
int trlm[][]=
new int
[501][501];
int trln[][]=new int[501][501];
PixelGrabber pg;
Color col;
Image img;
int w=500;
int h=500;
int red,green,blue;
int pix[]=new int[w*h];
int memor[][]=new int[h][w];
int memog[][]=new int[h][w];
int memob[][]=new int[h][w];
int wclothr[][]=new int[h][w];
int wclothg[][]=new int[h][w];
int wclothb[][]=new int[h][w];
int clothr[][]=new int[h][w];
int clothg[][]=new int[h][w];
int clothb[][]=new int[h][w];
int rgb[][]=new int[h][w];
int j;
int mx,nx,m,n;
int m1,n1,m2,n2;
int ex,ey;
int mode;
double b1,b2,c1,c2;
String s1,s2,s3,s4;
s1="fuku.jpg";
catchimg(s1);
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){
j=0;
if(memor[mx][nx]<50)j=j+1;
if(memog[mx][nx]<50)j=j+1;
if(memob[mx][nx]<50)j=j+1;
if(j==3)rgb[mx][nx]=
100;
}
}
s2="ron.jpg";
catchimg(s2);
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){
if(rgb[mx][nx]<50)clothr[mx][nx]=250;
if(rgb[mx][nx]<50)clothg[mx][nx]=250;
if(rgb[mx][nx]<50)clothb[mx][nx]=250;
}
}
x0=87;
x1=186;
y0=152;
y1=397;
for(mx=0;mx<501;mx++){
for(nx=0;nx<501;nx++){
trlocal(mx,nx);
trlm[mx][nx]=trm;
trln[mx][nx]=trn;
}
}
for(mx=0;mx<500;mx++){
for(nx=0;nx<500;nx++){
trm=trlm[mx][nx];
trn=trln[mx][nx];
wclothr[mx][nx]=clothr[trm][trn];
wclothg[mx][nx]=clothg[trm][trn];
wclothb[mx][nx]=clothb[trm][trn];
}
}
}
public static void main(String[] args) {
game0524 f = new game0524();
f.setSize(700,700);
f.setBackground(Color.blue) ;
f.setVisible(true);
f.addWindowListener(new WindowAdapter(){public void
windowClosing(WindowEvent e){System.exit(0);}});
}
public void paint( Graphics g ) {
g.setColor(Color.blue);
g.fillRect(0,0,700,700);
mx=1;
nx=1;
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){
g.setColor(new Color(memor[mx][nx],memog[mx][nx],memob[mx][nx]));
g.fillRect(nx+100,mx+100,1,1);
}
}
}
void catchimg(String s){
img = createImage(w,h);
img = Toolkit.getDefaultToolkit().getImage(s);
pg = new PixelGrabber(img,0,0,w,h,pix,0,w);
try{pg.grabPixels();}catch(InterruptedException ie){}
m=0;
n=0;
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[m][n]=red;
memog[m][n]=green;
memob[m][n]=blue;
n=n+1;
if (n==w)m=m+1;
if (n==w)n=0;
}
}
void trlocal(int mx,int nx){
double a0,a1,b0,b1;
a1=(double)(x1-x0)/300;
a0=x0-a1*100;
trn=(int)(a1*nx+a0);
if(trn<0)trn=0;
if(trn>499)trn=499;
b1=(double)(y1-y0)/300;
b0=y0-b1*100;
trm=(int)(b1*mx+b0);
if(trm<0)trm=0;
if(trm>499)trm=499;
}
}
最終更新:2011年02月24日 18:21