アットウィキロゴ

じゃヴぁ1026

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

class game1026 extends Frame{
int s,m;
double[] data=new double[501];
double[] gdata=new double[501];
double[] alpha=new double[101];
double delta;
int x;

public static void main(String args[]){
game1026 f=new game1026();
f.setTitle("game1026");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}

game1026(){

for (s=0;s<501;s++){
data[s]=s/2;
}

delta=(double)Math.PI/500;

for (m=0;m<101;m++){
alpha[m]=seekalpha(delta,m,data);
}

for (s=0;s<501;s++){
gdata[s]=seekfou(alpha,s*delta);
}

addWindowListener(new stopwin());
}

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


public static double seekfou(double[] alpha,double x){
double z;
int m;
z=alpha[0]/2;
for (m=1;m<100;m++){
z=z+alpha[m]*Math.cos(m*x);
}
return z;
}

public static double seekalpha(double delta,int m,double[] data){
int n,nx;
double x1,y1,z;
z=0;
for (n=-500;n<500;n++){
nx=n;
if (nx<0)nx=-nx;  
x1=nx*delta;  
y1=data[nx]*Math.cos(m*x1);  
z=z+delta*y1;
}
z=z/Math.PI;
return z;
}



public void paint(Graphics g){
int x1,x2;

g.drawLine(100,600,600,600);
g.drawLine(100,600,100,100);

g.setColor(Color.blue);
for (s=0;s<500;s++){
x1=(int)gdata[s];
x2=(int)gdata[s+1];
g.drawLine(100+s,600-x1,101+s,600-x2);
}

g.setColor(Color.red);
for (s=0;s<500;s++){
x1=(int)data[s];
x2=(int)data[s+1];
g.drawLine(100+s,600-x1,101+s,600-x2);
}

}

}
最終更新:2011年03月07日 17:09