Tugas06 171511049 Mufadhil Hisyamul Ilmi

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Nama : Mufadhil Hisyamul Ilmi 3 Januari 2019

NIM : 171511049 OOP Teori

Kelas : 2B / D3 – Teknik Informatika

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 {

public JavaGraphic() throws HeadlessException{


setSize(600,600);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setContentPane(new DrawArea());
setVisible(true);
}
public static void main(String[] args) {
// TODO code application logic here
new JavaGraphic();

}
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))));
}

}
}

II. Hasil Compile (ScreenShoot)

You might also like