import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
class game0725 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 body[][]=new int[h][w];
int mx,nx,m,n;
int m1,n1,m2,n2;
int j;
double a1,a0,z;
int x1,x2,y1,y2;
String s1,s2,s3,s4;
Button bu1,bu2,bu3,bu4,bu5,bu6;
game0725(){
s1="shinoda.jpg";
catchimg(s1);
x1=203;
y1=188;
x2=279;
y2=182;
a1=(double)(y2-y1)/(x2-x1);
a0=y1-a1*x1;
System.out.println(a0);
System.out.println(a1);
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;
}
}
}
public static void main(String[] args) {
game0725 f = new game0725();
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(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;
}
}
}
最終更新:2011年02月28日 00:24