アットウィキロゴ

かいてん0626

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

class game0626 extends Frame{
PixelGrabber pg;
Color col;
Image img;
int w=500;
int h=500;
int pix[]=new int[w*h];
int red,green,blue;
int memor[][]=new int[h][w];
int memog[][]=new int[h][w];
int memob[][]=new int[h][w];
int mr[][]=new int[h][w];
int mg[][]=new int[h][w];
int mb[][]=new int[h][w];

int body[][]=new int[h][w];
int atama[][]=new int[h][w];
int m,n,mx,nx,mxs,nxs;
int num;
double kakudo;
String s1;

game0626() {

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


kakudo=-10;
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){  
nxs=(int)rotx(kakudo,mx,nx);
mxs=(int)roty(kakudo,mx,nx);
if(mxs<0)mxs=0;
if(nxs<0)nxs=0;
if(mxs>499)mxs=499;
if(nxs>499)nxs=499;
mr[mxs][nxs]=memor[mx][nx];
mg[mxs][nxs]=memog[mx][nx];
mb[mxs][nxs]=memob[mx][nx];
}
}



}

public static void main(String[] args) {
game0626 f = new game0626();
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 ) {
mx=1;
nx=1;
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){  
g.setColor(new Color(mr[mx][nx],mg[mx][nx],mb[mx][nx]));
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,int x,int 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,int x,int 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月25日 19:17