All pastes #490084 Raw Edit

Stuff

public java v1 · immutable
·published 2007-05-15 20:53 UTC
rendered paste body
import java.applet.Applet;import java.awt.*;public class Farn extends Applet {    public void init(){        setBackground(Color.BLACK);    }        public void paint(Graphics g) {        setForeground(Color.WHITE);                zeichneFarn(g, 150, 650, 250, 550);    }        public void zeichneFarn(Graphics g, int x0, int y0, int x1, int y1) {        double x = x1 - x0;        double y = y1 - y0;        double laenge = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));                //System.out.println(laenge);                if (laenge <= 6) {            return;        }                g.drawLine(x0, y0, x1, y1);                double winkel = Math.atan2(y,x);                double winkel10 = winkel - Math.PI / 18;        double winkel50 = winkel + 5 * Math.PI / 18;        double winkel60 = winkel - Math.PI / 3;                //int x2 = (int) (Math.round(x1 + Math.sin(Math.PI / 18 * 5)));//x) / 2 + Math.cos(winkel50) * laenge / 2));        int x2 = (int) (x1 + 0.5*laenge*Math.cos(winkel50));        int x3 = (int) (x1 + 0.8*laenge*Math.cos(winkel10));        int x4 = (int) (x1 + 0.5*laenge*Math.cos(winkel60));                int y2 = (int) (y1 + 0.5*laenge*Math.sin(winkel50));        int y3 = (int) (y1 + 0.8*laenge*Math.sin(winkel10));        int y4 = (int) (y1 + 0.5*laenge*Math.sin(winkel60));        //int y2 = (int) (Math.round(y1 -  //y) / 2 + Math.sin(winkel50) * laenge / 2));                // hier steckt genau mein prob, deswegen nicht weiter ... alles andere ist abgeschrieben von der uebung ... aber das passt halt nicht :)        /*int x3 = (int) (Math.round((x1 + x) * 4 / 5 + Math.cos(winkel10) * laenge * 4 / 5));        int y3 = (int) (Math.round((y1 + y) * 4 / 5 + Math.sin(winkel10) * laenge * 4 / 5));        int x4 = (int) (Math.round((x1 + x) / 2 + Math.cos(winkel60) * laenge / 2));        int y4 = (int) (Math.round((y1 + y) / 2 + Math.sin(winkel60) * laenge / 2));        */        zeichneFarn(g, x1, y1, x2, y2);        zeichneFarn(g, x1, y1, x3, y3);        zeichneFarn(g, x1, y1, x4, y4);    }    }