アットウィキロゴ

j0726

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

class game0726 extends Frame{
PixelGrabber pg;
Color col;
Image img;
int w=500;
int h=500;
int size;
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 face[][]=new int[h][w];
int chr[][]=new int[h][w];
int chg[][]=new int[h][w];
int chb[][]=new int[h][w];
int body[][]=new int[h][w];
int mx,nx,m,n;
int m1,n1,m2,n2;      
int j;
int px,py;
double a1,a0,z;
double kakudo;
int x0,y0,x1,x2,y1,y2;
String s1,s2,s3,s4;
Button bu1,bu2,bu3,bu4,bu5,bu6;

game0726(){  

s1="shinoda.jpg";
catchimg(s1);  

x1=203;
y1=188;
x2=279;
y2=182;
x0=241;
y0=185;

a1=(double)(y2-y1)/(x2-x1);
a0=y1-a1*x1;



for (mx=0;mx<500;mx++){
for (nx=0;nx<500;nx++){  
h=0;
if(memor[mx][nx]<250)h=h+1;
if(memog[mx][nx]<250)h=h+1;
if(memob[mx][nx]<250)h=h+1;
z=a0+a1*nx-mx;
if(z<0)h=h+1;
if(z==0)h=h+1;
if(h==4)body[mx][nx]=100;
}
}

for (mx=0;mx<500;mx++){
for (nx=0;nx<500;nx++){  
h=0;
if(memor[mx][nx]<250)h=h+1;
if(memog[mx][nx]<250)h=h+1;
if(memob[mx][nx]<250)h=h+1;
z=a0+a1*nx-mx;
if(z>0)h=h+1;
if(z==0)h=h+1;
if(h==4)face[mx][nx]=100;
}
}

kakudo=30;

for (mx=0;mx<500;mx++){
for (nx=0;nx<500;nx++){
chr[mx][nx]=255;
chg[mx][nx]=255;
chb[mx][nx]=255;
}
}

for (mx=0;mx<500;mx++){
for (nx=0;nx<500;nx++){  
h=0;
if(face[mx][nx]>50)h=h+1;
px=x0+(int)rotx(kakudo,nx-x0,mx-y0);
py=y0+(int)roty(kakudo,nx-x0,mx-y0);
z=a0+a1*px-py;
if(z>0)h=h+1;
if(py>0)h=h+1;
if(h==3)chr[py][px]=memor[mx][nx];
if(h==3)chg[py][px]=memog[mx][nx];
if(h==3)chb[py][px]=memob[mx][nx];
}
}



}

public static void main(String[] args) {
game0726 f = new game0726();
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.white);
g.fillRect(0,0,700,700);
mx=1;
nx=1;
for (mx=0;mx<500;mx++){
for (nx=0;nx<500;nx++){  
g.setColor(new Color(chr[mx][nx],chg[mx][nx],chb[mx][nx]));  
g.fillRect(nx,mx,1,1);
}
}


for (mx=0;mx<500;mx++){
for (nx=0;nx<500;nx++){  
g.setColor(new Color(memor[mx][nx],memog[mx][nx],memob[mx][nx]));  
if(body[mx][nx]>50)g.fillRect(nx,mx,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;
}

}

public static double rotx(double kakudo,double x,double y){
double kaku;
double a1,a2,a3,a4;
double x1,y1;
kaku = kakudo*Math.PI/180;
a1=Math.cos(kaku);
a2=-Math.sin(kaku);
a3=Math.sin(kaku);
a4=Math.cos(kaku);
x1=a1*x+a2*y;
y1=a3*x+a4*y;
return x1;
}

public static double roty(double kakudo,double x,double y){
double kaku;
double a1,a2,a3,a4;
double x1,y1;
kaku = kakudo*Math.PI/180;
a1=Math.cos(kaku);
a2=-Math.sin(kaku);
a3=Math.sin(kaku);
a4=Math.cos(kaku);
x1=a1*x+a2*y;
y1=a3*x+a4*y;
return y1;
}


  
}
最終更新:2011年02月28日 00:54