Gambar (Output)
GIF(Output)
Coding & Penjelasan
import java.awt.*; import javax.swing.*; import java.awt.geom.*; import java.applet.*; public class tugasakhirfebi extends java.applet.Applet implements Runnable { int m=0; //Matahari int x=0; //Awan int y=0; //Mobilsedan int z=0; //Mobil Box Thread jln;
public void start(){ Thread jln=new Thread(this); jln.start(); } public void run(){ while (true) { //Gerak matahari if (m < 300) { //Panjang Lintasan m=m+7;//Kecepatan } if (m > 300) { m=-350;//Kedatangan Matahari } //Gerak awan if (x < 1000) { //Panjang Lintasan x=x+7;//Kecepatan } if (x > 1000) { x=-350;//Kedatangan Awan } //Gerak Mobil if (y < 800) { //Panjang Lintasan (Semakin panjang = lama muncul y=y+17;//Kecepatan Mobil } if (y > 800) { y=-800;//Kedatangan Mobil } //Gerak Mobil box if (z < 1000) { //Panjang Lintasan z=z+14;//Kecepatan Mobil Box } if (z > 1000) { z=-300;//Kedatangan Mobil Box } repaint(); try{ Thread.sleep(50); } catch (InterruptedException ex) { ex.printStackTrace(); }} }
public void paint(Graphics g) { //Latar Awal Color skyBlue = new Color(0,191,255); //Langit g.setColor(skyBlue); g.fillRect(0, 0,1020 ,320 ); Color Brown = new Color(102,51,0); g.setColor(Color.orange); //Matahari g.fillOval(490,120-m,170 ,170 ); g.setColor(Brown); //Tanah g.fillRect(0, 320,1020 ,300 ); //Pegunungan Color verydarkgreen = new Color(0,102,0); g.setColor(verydarkgreen); g.fillArc(200, 150, 400, 400, 0, 180); //Tengah g.fillArc(0, 175, 600, 350, 90,90 ); //Kiri g.fillArc(550, 75, 500, 550, 0, 180); //Kanan //Gambar Tanaman g.setColor(Color.green); g.fillOval(0, 500, 30,30); g.fillOval(25, 500, 30,30); g.fillOval(50, 500, 30,30); g.fillOval(15, 480, 30,30); g.fillOval(32, 480, 30,30); g.fillOval(90, 500, 30,30); g.fillOval(115, 500, 30,30); g.fillOval(140, 500, 30,30); g.fillOval(105, 480, 30,30); g.fillOval(122, 480, 30,30); g.fillOval(180, 500, 30,30); g.fillOval(205, 500, 30,30); g.fillOval(230, 500, 30,30); g.fillOval(195, 480, 30,30); g.fillOval(212, 480, 30,30); g.fillOval(270, 500, 30,30); g.fillOval(295, 500, 30,30); g.fillOval(320, 500, 30,30); g.fillOval(285, 480, 30,30); g.fillOval(302, 480, 30,30); g.fillOval(510, 500, 30,30); g.fillOval(535, 500, 30,30); g.fillOval(560, 500, 30,30); g.fillOval(525, 480, 30,30); g.fillOval(542, 480, 30,30); g.fillOval(600, 500, 30,30); g.fillOval(625, 500, 30,30); g.fillOval(650, 500, 30,30); g.fillOval(615, 480, 30,30); g.fillOval(632, 480, 30,30); g.fillOval(690, 500, 30,30); g.fillOval(715, 500, 30,30); g.fillOval(740, 500, 30,30); g.fillOval(705, 480, 30,30); g.fillOval(722, 480, 30,30); g.fillOval(780, 500, 30,30); g.fillOval(805, 500, 30,30); g.fillOval(830, 500, 30,30); g.fillOval(795, 480, 30,30); g.fillOval(812, 480, 30,30); g.fillOval(870, 500, 30,30); g.fillOval(895, 500, 30,30); g.fillOval(920, 500, 30,30); g.fillOval(885, 480, 30,30); g.fillOval(902, 480, 30,30); g.fillOval(960, 500, 30,30); g.fillOval(985, 500, 30,30); g.fillOval(1010, 500, 30,30); g.fillOval(975, 480, 30,30); g.fillOval(992, 480, 30,30); //Pohon sebrang g.setColor(Color.green); g.fillOval(600,220, 30,40); g.fillOval(590, 240, 30,30); g.fillOval(610, 240, 30,30); g.fillRect(610,260,9 ,60 ); g.setColor(Color.green); g.fillOval(660,220, 30,40); g.fillOval(650, 240, 30,30); g.fillOval(670, 240, 30,30); g.fillRect(670,260,9 ,60 ); //Jalan Aspal g.setColor(Color.black); g.fillRect(0, 300, 1020, 50); //Garis Jalan Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.white); float[] dash = {20.0f}; BasicStroke strok = new BasicStroke(3.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f, dash, 0.0f); g2d.setStroke(strok); g2d.draw(new Line2D.Double(10, 320, 1000, 320)); //Bendera g.setColor(Color.red); g.fillRect(100,120,100 ,35 ); g.setColor(Color.white); g.fillRect(100,150,100 ,35 ); g.fillRect(100,150,5 ,150 ); //MobilSedan g.setColor(Color.red); g.fillRect(205+y,285,100,30 ); //badan bawah g.fillOval(207+y,258,104,45); //badan atas g.setColor(Color.yellow); g.fillRect(210+y,285,100,30 ); //badan bawah g.fillOval(210+y,260,100,45); //badan atas g.fillArc (180+y,278,60,70,0,180);// atas ban g.fillArc (285+y,278,60,70,0,180);// atas ban g.setColor(Color.yellow); g.fillArc (318+y,281,23,23,0,80);// atas ban g.setColor(Color.black); //ban g.fillOval(198+y, 293, 32,32); //ban g.fillOval(298+y, 293, 32,32); //ban g.setColor(Color.white); //ban g.fillOval(204+y, 299, 20,20); //ban g.fillOval(304+y, 299, 20,20); //ban g.setColor(Color.red); g.fillArc (230+y,265,70,40,0,90);// atas ban g.setColor(Color.black); g.fillArc (234+y,266,64,36,0,90);// atas ban g.setColor(Color.red); g.fillArc (220+y,265,70,40,90,90);// atas ban g.setColor(Color.black); g.fillArc (223+y,266,68,36,90,90);// atas ban g.setColor(Color.red); g.fillRect(258+y,266,10,18 ); //Mobil Box g.setColor (Color.blue); g.fillRect (900-z, 280, 100, 60); //Kotak box int h[ ] = {900-z, 895-z, 860-z, 860-z, 900-z}; //Supir int i[ ] = {290, 290, 320, 340, 340}; g.fillPolygon (h, i, h.length); g.setColor (Color.yellow); int j[ ] = {870-z, 870-z, 860-z, 860-z, 870-z}; //Bagian Lampu int k[ ] = {313, 313, 320, 325, 325}; g.fillPolygon (j, k, j.length); g.setColor (Color.cyan); //Jendela g.fillRect (911-z, 290, 80, 30); g.setColor (Color.red);//Ban g.fillArc (907-z, 320, 27, 27, 0, 360); g.fillArc (968-z, 320, 27, 27, 0, 360); //Pohon Dekat g.setColor(Color.green); g.fillOval(720,250, 30,40); g.fillOval(710, 270, 30,30); g.fillOval(730, 270, 30,30); g.fillRect(730,290,9 ,60 ); g.setColor(Color.green); g.fillOval(780,250, 30,40); g.fillOval(770, 270, 30,30); g.fillOval(790, 270, 30,30); g.fillRect(790,290,9 ,60 ); //Gambar Awan g.setColor(Color.white); //Awan kiri atas g.fillOval(30+x,70,90,40); g.fillOval(70+x,70,90,40); g.fillOval(40+x, 60, 50,50); g.fillOval(90+x, 60, 50,50); //Awan kiri atas g.fillOval(210+x,90,90,40); g.fillOval(250+x,90,90,40); g.fillOval(220+x, 80, 50,50); g.fillOval(270+x, 80, 50,50); //Awan kanan g.fillOval(820-x,50,90,40); g.fillOval(860-x,50,90,40); g.fillOval(830-x,40, 50,50); g.fillOval(880-x,40, 50,50); //Latar Nama g.setColor(Color.white); g.fillRect(750, 500, 230 ,70 ); //Nama : Febi //N g.setColor(Color.black); g.fillRect(770,510,3,15 ); g2d.draw(new Line2D.Double(772, 512, 780, 522)); g.fillRect(780,510,3,15 ); //A g.fillRect(790,510,3,15 ); //Berdiri g.fillRect(800,510,3,15 ); //Berdiri g.fillRect(790,510,10,3 ); //Atas g.fillRect(790,517,10,3 ); //Tengah //M g.fillRect(810,510,3,15 ); //Tengah g.fillRect(818,510,3,15 ); //berdiri g.fillRect(826,510,3,15 ); //berdiri g.fillRect(810,510,16,3 ); //atas //A g.fillRect(835,510,3,15 ); //Berdiri g.fillRect(845,510,3,15 ); //Berdiri g.fillRect(835,510,10,3 ); //Atas g.fillRect(835,517,10,3 ); //Tengah //: g.fillRect(865,512,3,3 ); //Atas g.fillRect(865,520,3,3 ); //Bawah //F g.fillRect(890,510,3,15 ); //Berdiri g.fillRect(890,510,10,3 ); //Atas g.fillRect(890,516,10,3 ); //Tengah //E g.fillRect(910,510,3,15 ); //Berdiri g.fillRect(910,510,10,3 ); //Atas g.fillRect(910,516,10,3 ); //Tengah g.fillRect(910,522,10,3 ); //Bawah //B g.fillRect(930,510,3,15 ); //Berdiri g.fillRect(940,512,3,11 ); //Berdiri g.fillRect(930,510,10,3 ); //Atas g.fillRect(930,516,10,3 ); //Tengah g.fillRect(930,522,10,3 ); //Bawah //I g.fillRect(950,510,3,15 ); //Berdiri //NPM : 1649 //N g.setColor(Color.black); g.fillRect(770,540,3,15 ); g2d.draw(new Line2D.Double(772, 542, 780, 552)); g.fillRect(780,540,3,15 ); //P g.fillRect(790,540,3,15 ); //Berdiri g.fillRect(800,541,3,5 ); //Berdiri pendek g.fillRect(790,540,10,3 ); //Atas g.fillRect(790,546,10,3 ); //Tengah //M g.fillRect(810,540,3,15 ); //Tengah g.fillRect(818,540,3,15 ); //Berdiri g.fillRect(826,540,3,15 ); //Berdiri g.fillRect(810,540,16,3 ); //Atas //: g.fillRect(865,542,3,3 ); //Atas g.fillRect(865,550,3,3 ); //Bawah //1 g.fillRect(890,540,3,15 ); //Berdiri //6 g.fillRect(900,540,3,15 ); //Berdiri Kiri g.fillRect(910,547,3,8 ); //Berdiri Kanan g.fillRect(900,540,12,3 ); //Atas g.fillRect(900,547,10,3 ); //Tengah g.fillRect(900,553,12,3 ); //Bawah //4 g.fillRect(930,540,3,17 ); //Berdiri kiri g.fillRect(920,549,17,3 ); //Tengah g2d.draw(new Line2D.Double(923, 548, 929, 540)); //Diagonal //9 g.fillRect(951,540,3,15 ); //Berdiri kanan g.fillRect(941,540,3,7 ); //Berdiri kiri g.fillRect(941,540,12,3 ); //Atas g.fillRect(941,547,10,3 ); //Tengah g.fillRect(941,553,12,3 ); //Bawah } } |
Related Posts :
Contoh Konfigurasi NAT(Network Address Translation) di Huawei A. CONTOH KONFIGURASI 1. Static NAT (One o… Read More...
Konfigurasi IP Address Static dan DHCP di Huawei Dalam melakukan konfigurasi IP address pada komputer bisa dilakukan dengan static dan dinamis, adapaun diantaranya : STATIC 1. … Read More...
Contoh Konfigurasi Link Aggregation Di Huawei Switch CONTOH KONFIGURASI LINK AGGREGATION/PORT CHANNEL HUAWEI 1. Mode Manual a. &n… Read More...
Cara Mengatasi Error CredSSP Encryption Oracle Remediation dengan Klik Script Kalau pengen langsung ke cara mengatasi Silakan Scroll ke bawah, tapi sebaiknya baca penyebabnya terlebih dahulu.... CredSSP Credential S… Read More...
Welcome to Basic Networking - ppt downloadWelcome to Basic Networking - ppt download: Agenda Why even worry about networking? The Basics Definitions of common networking terms Compo… Read More...
0 Response to "Menggambar Dengan Coding Java"
Posting Komentar