SlideShare a Scribd company logo
1 of 10
Npm : 201243501228
Nama : Syahroni
Kelas : R7H
Mata Kuliah : Komputer Grafik
Dosen : Nahot Frastian , M.Kom
Program Studi : Teknik Informatika
Universitas : Universitas Indraprasta Pgri
Program Komputer Grafik :
- Soal no 3
Input :
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class tugasno3 extends JApplet {
public static void main(String s[]) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JApplet applet = new tugasno3();
applet.init();
frame.getContentPane().add(applet);
frame.pack();
frame.setVisible(true);
}
public void init() {
JPanel panel = new Pan();
getContentPane().add(panel);
}
class Pan extends JPanel {
public Pan() {
setPreferredSize(new Dimension(600, 600));
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g1 = (Graphics2D) g;
Graphics2D g2 = (Graphics2D) g;
kotak(g2);
//GradientPaint paint1 = new GradientPaint(100, 100, new Color(130,
36, 2), 250, 100, new Color(253, 149, 51));
kotak_brass(g2, 50, 320, 350, 370);
kotak_brass(g2, 250, 320, 350, 370);
budermidpoint(g2, 50, 50, 50);
garisdda(g2, 100, 20, 200, 20);
garisdda(g2, 110, 60,200,90);
garisdda(g2, 90, 100,170,160);
garisdda(g2, 50, 120,100,190);
body(g2);
int x[] = {0,250, 500};
int y[] = {320, 180, 320};
Polygon sgtga = new Polygon(x,y,3);
g2.setPaint(Color.red);
g2.fill(sgtga);
Rectangle2D rec= new Rectangle2D.Double(80,370,60,100);
g2.setColor(Color.GRAY);
g2.fill(rec);
Rectangle2D rect= new Rectangle2D.Double(190,350,50,50);
g2.setColor(Color.yellow);
g2.fill(rect);
bundermidpoint2(g2, 125, 405, 7);
Rectangle2D rec1= new Rectangle2D.Double(280,370,60,100);
g2.setColor(Color.gray);
g2.fill(rec1);
Rectangle2D rect1= new Rectangle2D.Double(360,350,60,60);
g2.setColor(Color.yellow);
g2.fill(rect1);
bundermidpoint2(g2, 325, 405, 7); }
public void body(Graphics2D g) {
GeneralPath gp = new GeneralPath();
GradientPaint p = new GradientPaint(0, 350, Color.gray, 50, 30,
Color.black);
g.setPaint(p);
gp.moveTo(280, 470);
gp.lineTo(220, 600);
gp.lineTo(370,600);
gp.lineTo(340,470);
gp.closePath();
g.fill(gp);
} public void kotak_brass(Graphics2D gr, int x_awal, int y_awal, int
x_akhir, int y_akhir) {
GeneralPath gp = new GeneralPath();
Shape s = new Rectangle2D.Double(x_awal, y_awal, 200, 150);
GradientPaint p = new GradientPaint(250, 400, Color.magenta, 550, 200,
Color.white);
gr.setPaint(p);
gr.fill(s);
int Dx = Math.abs(x_akhir - x_awal);
int Dy = Math.abs(y_akhir - y_awal);
int parameter = (2 * Dy) - Dx;
String status = "Kotak_BM";
this.repaint();
double g = x_awal, h = y_awal;
while (x_awal < x_akhir) {
if (parameter < 0) {
parameter += (2 * Dy);
} else {
y_awal++;
parameter = parameter + (2 * Dy) - (2 * Dx);
}
gp.moveTo(x_awal, y_awal);
x_awal++;
}
gp.lineTo(g, y_awal);
gp.lineTo(g, h);
gp.lineTo(x_awal, h);
gp.lineTo(x_awal, y_awal);
gp.closePath();
gr.draw(gp);
}
public void kotak_brass2(Graphics2D gr, int x_awal, int y_awal, int
x_akhir, int y_akhir) {
GeneralPath gp2 = new GeneralPath();
Shape s2 = new Rectangle2D.Double(x_awal, y_awal, 20, 130);
gr.setPaint(new Color(153, 102, 0));
gr.fill(s2);
int Dx = Math.abs(x_akhir - x_awal);
int Dy = Math.abs(y_akhir - y_awal);
int parameter = (2 * Dy) - Dx;
String status = "Kotak_BM";
this.repaint();
double g = x_awal, h = y_awal;
while (x_awal < x_akhir) {
if (parameter < 0) {
parameter += (2 * Dy); } else {
y_awal++;
parameter = parameter + (2 * Dy) - (2 * Dx); }
gp2.moveTo(x_awal, y_awal);
x_awal++; }
gp2.lineTo(g, y_awal);
gp2.lineTo(g, h);
gp2.lineTo(x_awal, h);
gp2.lineTo(x_awal, y_awal);
gp2.closePath();
gr.draw(gp2); }
public void garisdda(Graphics2D g, int x1, int y1, int x2, int y2) {
double m = (double) (y2 - y1) / (x2 - x1);
double y = (double) y1;
int iy;
for (int x = x1; x <= x2; x++) {
iy = (int) Math.round(y);
g.drawLine(x, iy, x, iy);
y += m; } } }
public void kotak(Graphics2D g) {
Shape s = new Rectangle2D.Double(0, 0, 1300, 550);
GradientPaint p = new GradientPaint(0, 350, new Color(0, 255, 255), 50,
30, new Color(70, 51, 204));
g.setPaint(p);
g.fill(s);
Shape s1 = new Rectangle2D.Double(0, 370, 1300, 250);
GradientPaint r = new GradientPaint(0, 250, Color.gray, 700, 600,
Color.white);
g.setPaint(r);
g.fill(s1); }
void budermidpoint(Graphics2D g, int x1, int y1, int r) {
Shape s = new Ellipse2D.Double(x1 - r, y1 - r, r * 2, r * 2);
g.setColor(Color.orange);
g.fill(s);
int x = 0, y = r, p = 1 - r;
int xctr = x1, yctr = y1;
g.drawLine(xctr + x, yctr + y, xctr + x, yctr + y);
g.drawLine(xctr - x, yctr + y, xctr - x, yctr + y);
g.drawLine(xctr + x, yctr - y, xctr + x, yctr - y);
g.drawLine(xctr - x, yctr - y, xctr - x, yctr - y);
g.drawLine(xctr + y, yctr + x, xctr + y, yctr + x);
g.drawLine(xctr - y, yctr + x, xctr - y, yctr + x);
g.drawLine(xctr + y, yctr - x, xctr + y, yctr - x);
g.drawLine(xctr - y, yctr - x, xctr - y, yctr - x);
while (x < y) {
x++;
if (p < 0) {
p += 2 * x + 1;
} else {
y--;
p += 2 * (x - y) + 1;
}
}
}
void bundermidpoint(Graphics2D g, int x1, int y1, int r) {
Shape s = new Ellipse2D.Double(x1 - r, y1 - r, r * 2, r * 2);
g.setColor(Color.cyan);
g.fill(s);
int x = 0, y = r, p = 1 - r;
int xctr = x1, yctr = y1;
g.drawLine(xctr + x, yctr + y, xctr + x, yctr + y);
g.drawLine(xctr - x, yctr + y, xctr - x, yctr + y);
g.drawLine(xctr + x, yctr - y, xctr + x, yctr - y);
g.drawLine(xctr - x, yctr - y, xctr - x, yctr - y);
g.drawLine(xctr + y, yctr + x, xctr + y, yctr + x);
g.drawLine(xctr - y, yctr + x, xctr - y, yctr + x);
g.drawLine(xctr + y, yctr - x, xctr + y, yctr - x);
g.drawLine(xctr - y, yctr - x, xctr - y, yctr - x);
while (x < y) {
x++;
if (p < 0) {
p += 2 * x + 1;
} else {
y--;
p += 2 * (x - y) + 1;
}
}
}
void bundermidpoint2(Graphics2D g, int x1, int y1, int r) {
Shape s = new Ellipse2D.Double(x1 - r, y1 - r, r * 2, r * 2);
g.setColor(Color.darkGray);
g.fill(s);
int x = 0, y = r, p = 1 - r;
int xctr = x1, yctr = y1;
g.drawLine(xctr + x, yctr + y, xctr + x, yctr + y);
g.drawLine(xctr - x, yctr + y, xctr - x, yctr + y);
g.drawLine(xctr + x, yctr - y, xctr + x, yctr - y);
g.drawLine(xctr - x, yctr - y, xctr - x, yctr - y);
g.drawLine(xctr + y, yctr + x, xctr + y, yctr + x);
g.drawLine(xctr - y, yctr + x, xctr - y, yctr + x);
g.drawLine(xctr + y, yctr - x, xctr + y, yctr - x);
g.drawLine(xctr - y, yctr - x, xctr - y, yctr - x);
while (x < y) {
x++;
if (p < 0) {
p += 2 * x + 1;
} else {
y--;
p += 2 * (x - y) + 1;
}
}
}
public void bunder(Graphics2D g, int x1, int y1, int r) {
Shape s = new Ellipse2D.Double(x1 - r, y1 - r, r * 2, r * 2);
GradientPaint p = new GradientPaint(x1, y1, Color.orange, x1 + 200, y1 +
50, Color.red);
g.setPaint(p);
g.fill(s);
}
public void awane(Graphics2D g2, int x, int y) {
GeneralPath gp = new GeneralPath();
gp.moveTo(30 + x, 80 + y);
gp.curveTo(-5 + x, 60 + y, 22 + x, 15 + y, 40 + x, 42 + y);
gp.curveTo(37 + x, 31 + y, 53 + x, 31 + y, 58 + x, 43 + y);
gp.curveTo(60 + x, 7 + y, 116 + x, 4 + y, 100 + x, 34 + y);
gp.curveTo(150 + x, 29 + y, 150 + x, 89 + y, 120 + x, 90 + y);
gp.curveTo(100 + x, 120 + y, 95 + x, 97 + y, 87 + x, 100 + y);
gp.curveTo(71 + x, 120 + y, 35 + x, 100 + y, 35 + x, 70 + y);
gp.closePath();
gp.closePath();
g2.setPaint(new GradientPaint(0 + x, 20 + y, Color.lightGray, 0 + x, 150 +
y, Color.white));
g2.fill(gp);
g2.setColor(Color.white);
g2.draw(gp);}}
Output :

More Related Content

What's hot

Tugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadratTugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadrattrisnasariasih
 
8-5 Adding and Subtracting Rational Expressions
8-5 Adding and Subtracting Rational Expressions8-5 Adding and Subtracting Rational Expressions
8-5 Adding and Subtracting Rational Expressionsrfrettig
 
Calculus First Test 2011/10/20
Calculus First Test 2011/10/20Calculus First Test 2011/10/20
Calculus First Test 2011/10/20Kuan-Lun Wang
 
Matematika Ekonomi Diferensiasi fungsi sederhana
Matematika Ekonomi Diferensiasi fungsi sederhanaMatematika Ekonomi Diferensiasi fungsi sederhana
Matematika Ekonomi Diferensiasi fungsi sederhanalia170494
 
Pde unit 1
Pde unit 1Pde unit 1
Pde unit 1Rajini10
 
last lecture in infinite series
last lecture in infinite serieslast lecture in infinite series
last lecture in infinite seriesAlaa Mohammed
 
4.1 implicit differentiation
4.1 implicit differentiation4.1 implicit differentiation
4.1 implicit differentiationdicosmo178
 
Lesson 11: Implicit Differentiation
Lesson 11: Implicit DifferentiationLesson 11: Implicit Differentiation
Lesson 11: Implicit DifferentiationMatthew Leingang
 
Pt 3&4 turunan fungsi implisit dan cyclometri
Pt 3&4 turunan fungsi implisit dan cyclometriPt 3&4 turunan fungsi implisit dan cyclometri
Pt 3&4 turunan fungsi implisit dan cyclometrilecturer
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.UA Mobile
 

What's hot (20)

Lesson 15: The Chain Rule
Lesson 15: The Chain RuleLesson 15: The Chain Rule
Lesson 15: The Chain Rule
 
Derivadas
DerivadasDerivadas
Derivadas
 
Calculus Final Exam
Calculus Final ExamCalculus Final Exam
Calculus Final Exam
 
Tugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadratTugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadrat
 
8-5 Adding and Subtracting Rational Expressions
8-5 Adding and Subtracting Rational Expressions8-5 Adding and Subtracting Rational Expressions
8-5 Adding and Subtracting Rational Expressions
 
Calculus First Test 2011/10/20
Calculus First Test 2011/10/20Calculus First Test 2011/10/20
Calculus First Test 2011/10/20
 
Matematika Ekonomi Diferensiasi fungsi sederhana
Matematika Ekonomi Diferensiasi fungsi sederhanaMatematika Ekonomi Diferensiasi fungsi sederhana
Matematika Ekonomi Diferensiasi fungsi sederhana
 
gfg
gfggfg
gfg
 
SOAL RANGKAIAN LOGIKA
SOAL RANGKAIAN LOGIKASOAL RANGKAIAN LOGIKA
SOAL RANGKAIAN LOGIKA
 
整卷
整卷整卷
整卷
 
Pde unit 1
Pde unit 1Pde unit 1
Pde unit 1
 
Ocr code
Ocr codeOcr code
Ocr code
 
Lagrange
LagrangeLagrange
Lagrange
 
last lecture in infinite series
last lecture in infinite serieslast lecture in infinite series
last lecture in infinite series
 
4.1 implicit differentiation
4.1 implicit differentiation4.1 implicit differentiation
4.1 implicit differentiation
 
Lesson 11: Implicit Differentiation
Lesson 11: Implicit DifferentiationLesson 11: Implicit Differentiation
Lesson 11: Implicit Differentiation
 
Pt 3&4 turunan fungsi implisit dan cyclometri
Pt 3&4 turunan fungsi implisit dan cyclometriPt 3&4 turunan fungsi implisit dan cyclometri
Pt 3&4 turunan fungsi implisit dan cyclometri
 
Chapter 2(limits)
Chapter 2(limits)Chapter 2(limits)
Chapter 2(limits)
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.
 
Divisor de 7
Divisor de 7Divisor de 7
Divisor de 7
 

Similar to No3

import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfanyacarpets
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineersvarun arora
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graphkinan keshkeh
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignmentAbdullah Al Shiam
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsKandarp Tiwari
 
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdf
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdfImport java.awt.; Import acm.program.; Import acm.graphics.;.pdf
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdfapexcomputer54
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision DetectionJenchoke Tachagomain
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2MEJenchoke Tachagomain
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)theijes
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
Geo Spatial Plot using R
Geo Spatial Plot using R Geo Spatial Plot using R
Geo Spatial Plot using R Rupak Roy
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 
Graphics programs
Graphics programsGraphics programs
Graphics programsNAVYA RAO
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talkshonjo2
 

Similar to No3 (20)

import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdf
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdfImport java.awt.; Import acm.program.; Import acm.graphics.;.pdf
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdf
 
662305 LAB12
662305 LAB12662305 LAB12
662305 LAB12
 
Graphics point clipping c program
Graphics point clipping c programGraphics point clipping c program
Graphics point clipping c program
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Geo Spatial Plot using R
Geo Spatial Plot using R Geo Spatial Plot using R
Geo Spatial Plot using R
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
Graphics programs
Graphics programsGraphics programs
Graphics programs
 
C++ TUTORIAL 10
C++ TUTORIAL 10C++ TUTORIAL 10
C++ TUTORIAL 10
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talks
 

More from syahronirpl (20)

Makalah Kelompok 10
Makalah Kelompok 10Makalah Kelompok 10
Makalah Kelompok 10
 
Dokumen
DokumenDokumen
Dokumen
 
Soalno2
Soalno2Soalno2
Soalno2
 
Soalno1b
Soalno1bSoalno1b
Soalno1b
 
Soalno1a
Soalno1aSoalno1a
Soalno1a
 
Segi empat1
Segi empat1Segi empat1
Segi empat1
 
Segi empat
Segi empatSegi empat
Segi empat
 
Polygonbiasa
PolygonbiasaPolygonbiasa
Polygonbiasa
 
Polygon
PolygonPolygon
Polygon
 
Oval
OvalOval
Oval
 
My line
My lineMy line
My line
 
Lamp
LampLamp
Lamp
 
Kotak3 d
Kotak3 dKotak3 d
Kotak3 d
 
Grafik
GrafikGrafik
Grafik
 
Eliptikal
EliptikalEliptikal
Eliptikal
 
Draw text
Draw textDraw text
Draw text
 
Bintang
BintangBintang
Bintang
 
Batang
BatangBatang
Batang
 
Basis graphics
Basis graphicsBasis graphics
Basis graphics
 
Arc
ArcArc
Arc
 

Recently uploaded

SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

No3

  • 1. Npm : 201243501228 Nama : Syahroni Kelas : R7H Mata Kuliah : Komputer Grafik Dosen : Nahot Frastian , M.Kom Program Studi : Teknik Informatika Universitas : Universitas Indraprasta Pgri
  • 2. Program Komputer Grafik : - Soal no 3 Input : import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class tugasno3 extends JApplet { public static void main(String s[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JApplet applet = new tugasno3(); applet.init(); frame.getContentPane().add(applet); frame.pack(); frame.setVisible(true); } public void init() { JPanel panel = new Pan(); getContentPane().add(panel); } class Pan extends JPanel { public Pan() { setPreferredSize(new Dimension(600, 600)); } public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g1 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g; kotak(g2); //GradientPaint paint1 = new GradientPaint(100, 100, new Color(130, 36, 2), 250, 100, new Color(253, 149, 51));
  • 3. kotak_brass(g2, 50, 320, 350, 370); kotak_brass(g2, 250, 320, 350, 370); budermidpoint(g2, 50, 50, 50); garisdda(g2, 100, 20, 200, 20); garisdda(g2, 110, 60,200,90); garisdda(g2, 90, 100,170,160); garisdda(g2, 50, 120,100,190); body(g2); int x[] = {0,250, 500}; int y[] = {320, 180, 320}; Polygon sgtga = new Polygon(x,y,3); g2.setPaint(Color.red); g2.fill(sgtga); Rectangle2D rec= new Rectangle2D.Double(80,370,60,100); g2.setColor(Color.GRAY); g2.fill(rec); Rectangle2D rect= new Rectangle2D.Double(190,350,50,50); g2.setColor(Color.yellow); g2.fill(rect); bundermidpoint2(g2, 125, 405, 7); Rectangle2D rec1= new Rectangle2D.Double(280,370,60,100); g2.setColor(Color.gray); g2.fill(rec1); Rectangle2D rect1= new Rectangle2D.Double(360,350,60,60); g2.setColor(Color.yellow); g2.fill(rect1); bundermidpoint2(g2, 325, 405, 7); } public void body(Graphics2D g) { GeneralPath gp = new GeneralPath(); GradientPaint p = new GradientPaint(0, 350, Color.gray, 50, 30, Color.black); g.setPaint(p); gp.moveTo(280, 470); gp.lineTo(220, 600); gp.lineTo(370,600); gp.lineTo(340,470); gp.closePath(); g.fill(gp); } public void kotak_brass(Graphics2D gr, int x_awal, int y_awal, int x_akhir, int y_akhir) {
  • 4. GeneralPath gp = new GeneralPath(); Shape s = new Rectangle2D.Double(x_awal, y_awal, 200, 150); GradientPaint p = new GradientPaint(250, 400, Color.magenta, 550, 200, Color.white); gr.setPaint(p); gr.fill(s); int Dx = Math.abs(x_akhir - x_awal); int Dy = Math.abs(y_akhir - y_awal); int parameter = (2 * Dy) - Dx; String status = "Kotak_BM"; this.repaint(); double g = x_awal, h = y_awal; while (x_awal < x_akhir) { if (parameter < 0) { parameter += (2 * Dy); } else { y_awal++; parameter = parameter + (2 * Dy) - (2 * Dx); } gp.moveTo(x_awal, y_awal); x_awal++; } gp.lineTo(g, y_awal); gp.lineTo(g, h); gp.lineTo(x_awal, h); gp.lineTo(x_awal, y_awal); gp.closePath(); gr.draw(gp); } public void kotak_brass2(Graphics2D gr, int x_awal, int y_awal, int x_akhir, int y_akhir) { GeneralPath gp2 = new GeneralPath(); Shape s2 = new Rectangle2D.Double(x_awal, y_awal, 20, 130); gr.setPaint(new Color(153, 102, 0)); gr.fill(s2); int Dx = Math.abs(x_akhir - x_awal); int Dy = Math.abs(y_akhir - y_awal); int parameter = (2 * Dy) - Dx; String status = "Kotak_BM";
  • 5. this.repaint(); double g = x_awal, h = y_awal; while (x_awal < x_akhir) { if (parameter < 0) { parameter += (2 * Dy); } else { y_awal++; parameter = parameter + (2 * Dy) - (2 * Dx); } gp2.moveTo(x_awal, y_awal); x_awal++; } gp2.lineTo(g, y_awal); gp2.lineTo(g, h); gp2.lineTo(x_awal, h); gp2.lineTo(x_awal, y_awal); gp2.closePath(); gr.draw(gp2); } public void garisdda(Graphics2D g, int x1, int y1, int x2, int y2) { double m = (double) (y2 - y1) / (x2 - x1); double y = (double) y1; int iy; for (int x = x1; x <= x2; x++) { iy = (int) Math.round(y); g.drawLine(x, iy, x, iy); y += m; } } } public void kotak(Graphics2D g) { Shape s = new Rectangle2D.Double(0, 0, 1300, 550); GradientPaint p = new GradientPaint(0, 350, new Color(0, 255, 255), 50, 30, new Color(70, 51, 204)); g.setPaint(p); g.fill(s); Shape s1 = new Rectangle2D.Double(0, 370, 1300, 250); GradientPaint r = new GradientPaint(0, 250, Color.gray, 700, 600, Color.white); g.setPaint(r); g.fill(s1); } void budermidpoint(Graphics2D g, int x1, int y1, int r) { Shape s = new Ellipse2D.Double(x1 - r, y1 - r, r * 2, r * 2); g.setColor(Color.orange); g.fill(s); int x = 0, y = r, p = 1 - r; int xctr = x1, yctr = y1;
  • 6. g.drawLine(xctr + x, yctr + y, xctr + x, yctr + y); g.drawLine(xctr - x, yctr + y, xctr - x, yctr + y); g.drawLine(xctr + x, yctr - y, xctr + x, yctr - y); g.drawLine(xctr - x, yctr - y, xctr - x, yctr - y); g.drawLine(xctr + y, yctr + x, xctr + y, yctr + x); g.drawLine(xctr - y, yctr + x, xctr - y, yctr + x); g.drawLine(xctr + y, yctr - x, xctr + y, yctr - x); g.drawLine(xctr - y, yctr - x, xctr - y, yctr - x); while (x < y) { x++; if (p < 0) { p += 2 * x + 1; } else { y--; p += 2 * (x - y) + 1; } } } void bundermidpoint(Graphics2D g, int x1, int y1, int r) { Shape s = new Ellipse2D.Double(x1 - r, y1 - r, r * 2, r * 2); g.setColor(Color.cyan); g.fill(s); int x = 0, y = r, p = 1 - r; int xctr = x1, yctr = y1; g.drawLine(xctr + x, yctr + y, xctr + x, yctr + y); g.drawLine(xctr - x, yctr + y, xctr - x, yctr + y); g.drawLine(xctr + x, yctr - y, xctr + x, yctr - y); g.drawLine(xctr - x, yctr - y, xctr - x, yctr - y); g.drawLine(xctr + y, yctr + x, xctr + y, yctr + x); g.drawLine(xctr - y, yctr + x, xctr - y, yctr + x); g.drawLine(xctr + y, yctr - x, xctr + y, yctr - x); g.drawLine(xctr - y, yctr - x, xctr - y, yctr - x); while (x < y) { x++; if (p < 0) { p += 2 * x + 1; } else { y--; p += 2 * (x - y) + 1; }
  • 7. } } void bundermidpoint2(Graphics2D g, int x1, int y1, int r) { Shape s = new Ellipse2D.Double(x1 - r, y1 - r, r * 2, r * 2); g.setColor(Color.darkGray); g.fill(s); int x = 0, y = r, p = 1 - r; int xctr = x1, yctr = y1; g.drawLine(xctr + x, yctr + y, xctr + x, yctr + y); g.drawLine(xctr - x, yctr + y, xctr - x, yctr + y); g.drawLine(xctr + x, yctr - y, xctr + x, yctr - y); g.drawLine(xctr - x, yctr - y, xctr - x, yctr - y); g.drawLine(xctr + y, yctr + x, xctr + y, yctr + x); g.drawLine(xctr - y, yctr + x, xctr - y, yctr + x); g.drawLine(xctr + y, yctr - x, xctr + y, yctr - x); g.drawLine(xctr - y, yctr - x, xctr - y, yctr - x); while (x < y) { x++; if (p < 0) { p += 2 * x + 1; } else { y--; p += 2 * (x - y) + 1; } } } public void bunder(Graphics2D g, int x1, int y1, int r) { Shape s = new Ellipse2D.Double(x1 - r, y1 - r, r * 2, r * 2); GradientPaint p = new GradientPaint(x1, y1, Color.orange, x1 + 200, y1 + 50, Color.red); g.setPaint(p); g.fill(s); } public void awane(Graphics2D g2, int x, int y) { GeneralPath gp = new GeneralPath(); gp.moveTo(30 + x, 80 + y); gp.curveTo(-5 + x, 60 + y, 22 + x, 15 + y, 40 + x, 42 + y); gp.curveTo(37 + x, 31 + y, 53 + x, 31 + y, 58 + x, 43 + y);
  • 8. gp.curveTo(60 + x, 7 + y, 116 + x, 4 + y, 100 + x, 34 + y); gp.curveTo(150 + x, 29 + y, 150 + x, 89 + y, 120 + x, 90 + y); gp.curveTo(100 + x, 120 + y, 95 + x, 97 + y, 87 + x, 100 + y); gp.curveTo(71 + x, 120 + y, 35 + x, 100 + y, 35 + x, 70 + y); gp.closePath(); gp.closePath(); g2.setPaint(new GradientPaint(0 + x, 20 + y, Color.lightGray, 0 + x, 150 + y, Color.white)); g2.fill(gp); g2.setColor(Color.white); g2.draw(gp);}}
  • 9.