アットウィキロゴ

senntaku

import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import java.io.IOException;

public class pro extends JFrame{
  public static void main(String[] args){
    pro test = new pro();

    test.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent e){System.exit(0);}
    });

    test.setBounds( 0, 0, 700, 700);
    test.setVisible(true);
  }

  public void paint(Graphics g){
double x,y,z;
int px,py;
    Graphics2D g2 = (Graphics2D)g;

    BufferedImage readImage = null;
    

    if (readImage == null){
      readImage = new BufferedImage(getWidth(), getHeight(),
        BufferedImage.TYPE_INT_BGR);
    }

    Graphics2D off = readImage.createGraphics();

    off.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);

BasicStroke wideStroke = new BasicStroke(2.0f);
    off.setStroke(wideStroke);

off.setPaint(Color.blue);

x=0;
y=0;
z=500;
px=pointx(x,y,z);
py=pointy(x,y,z);
off.drawLine(100,600,100+px,600-py);    

x=500;
y=0;
z=0;
px=pointx(x,y,z);
py=pointy(x,y,z);
off.drawLine(100,600,100+px,600-py);

x=0;
y=500;
z=0;
px=pointx(x,y,z);
py=pointy(x,y,z);
off.drawLine(100,600,100+px,600-py);

    
    if (readImage != null){g2.drawImage(readImage,0,0, this);}

    try {
      boolean result =
       ImageIO.write(readImage, "jpg", new File("sam.jpg"));
    } catch (Exception e) {
        e.printStackTrace();
    }
  }

public static int pointy(double x,double y,double z){
int p2;
double theta,phi;
theta=-0.222222*Math.PI;
phi=0.333333*Math.PI;
p2=(int)(-Math.cos(theta)*Math.cos(phi)*x-Math.sin(theta)*Math.cos(phi)*y+Math.sin(phi)*z);
return p2;
}


public static int pointx(double x,double y,double z){
int p1;
double theta;
theta=-0.222222*Math.PI;
p1=(int)(-Math.sin(theta)*x+Math.cos(theta)*y);
return p1;
}




}
最終更新:2010年11月04日 08:03