Professional Documents
Culture Documents
Tugas06 171511049 Mufadhil Hisyamul Ilmi
Tugas06 171511049 Mufadhil Hisyamul Ilmi
Tugas06 171511049 Mufadhil Hisyamul Ilmi
I. Source Code
1. JavaGraphic.java
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javagraphic;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.HeadlessException;
import java.awt.Point;
import static java.lang.Math.*;
/**
*
* @author ASUS
*/
public class JavaGraphic extends JFrame {
}
class DrawArea extends JPanel{
Point A = null;
int nbrOfLoops = 100;
int length = 100;
public DrawArea(){
A = new Point(250,250);
}
@Override
protected void paintComponent(Graphics g){
g.fillRect(0, 0, 800, 700);
g.setColor(Color.orange);
for (int i = 0; i < 400;i++){
g.drawLine(A.x +(int)(length * cos(PI *
i/200.0)*(1 - cos(nbrOfLoops * PI * i /200.00))),
A.y +(int)(length * sin(PI *
i/200.0)*(1 - cos(nbrOfLoops * PI * i /200.00))),
A.x +(int)(length * cos(PI *
(i+1)/200.0)*(1 - cos(nbrOfLoops * PI * (i+1) /200.00))),
A.x +(int)(length * sin(PI *
(i+1)/200.0)*(1 - cos(nbrOfLoops * PI * (i+1) /200.00))));
}
}
}