Assalammualaikum Wr.Wb
Kali ini saya akan menggambar rumah,awan,matahari,dan android dengan menggunakan JAVA berikut ini adalah codingnya:
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
public class studykasus extends Canvas {
//untuk mengatur koordinat atap rumah
int xPoint[] = {320, 370, 240};
int yPoint[] = {240, 370, 340};
public void paint(Graphics g)
{
//coding langit
g.setColor(Color.blue);
g.fillRect(0, 0, 500, 500);
int yPoint[] = {240, 370, 340};
public void paint(Graphics g)
{
//coding langit
g.setColor(Color.blue);
g.fillRect(0, 0, 500, 500);
//coding matahari
g.setColor(Color.yellow);
g.fillOval(100, 40, 60, 60);
g.drawLine(80, 40, 90, 50);
g.drawLine(130, 20, 130, 30);
g.drawLine(170, 40, 160, 50);
g.drawLine(80, 100, 100, 90);
g.drawLine(130, 130, 130, 110);
g.drawLine(180, 100, 160, 90);
//coding awan
g.setColor(new Color(0,255,255));
g.fillOval(200, 40, 60, 20);
g.fillOval(230, 20, 65, 30);
g.fillOval(280, 30, 70, 30);
//coding android
g.setColor(Color.GREEN);
g.fillArc(80, 320, 70, 50, -180, -180);
g.drawLine(80, 345, 149, 345);
g.setColor(Color.BLACK);
g.fillOval(103, 330, 7, 7);
g.fillOval(123, 330, 7, 7);
g.setColor(Color.GREEN);
g.fillRect(80, 355, 70, 50);
g.fillRoundRect(65, 350, 10, 60, 10, 10);
g.fillRoundRect(155, 350, 10, 60, 10, 10);
g.fillRoundRect(90, 405, 10, 35, 10, 10);
g.fillRoundRect(127, 405, 10, 35, 10, 10);
//coding rumah
g.setColor(Color.red);
g.fillPolygon(xPoint, yPoint, 3);
g.setColor(Color.yellow);
g.fillRect(240, 340, 130, 120);
g.setColor(Color.white);
g.fillRect(320, 345, 40, 40);
g.setColor(Color.black);
g.drawLine(320, 365, 360, 365);
g.drawLine(340, 385, 340, 345);
g.fillRect(290, 400, 40, 60);
}
public static void main(String[] args) {
Frame f = new Frame("Study Kasus");
studykasus cv = new studykasus();
f.add(cv);
f.setSize(600, 600);
f.setVisible(true);
}
}
Sekian dan terima kasih mohon maaf bila ada kesalahan.
Wassalammualaiku Wr.Wb.