Results 1 to 7 of 7
Thread: Simple Graphics
- 10-04-2010, 11:38 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 27
- Rep Power
- 0
Simple Graphics
Hello guys, I am learning how to make ovals, rectangles, and all of the simple applet stuff right now. But I have some problems to understand how the coordinates work while trying to use all those figures to make drawings like a pumpkin, train etc.(Which i have the code but don't understand them). So my question is how the coordinates work and how can I draw the figure (in paper o I have heard people said that they used photoshop) before I write the code so that i can know in which coordinate and weight, height to make the drawing look nice?
- 10-05-2010, 01:37 AM #2
Best way I think is to find or write a simple program and try out various things to see how they work. Read the API doc for the Graphics and Graphics2D classes to see how their methods work. Then change your simple program to try using what you have read about.
If you have questions about your code, post the code and your questions.
- 10-05-2010, 02:12 AM #3
Member
- Join Date
- Jul 2010
- Posts
- 27
- Rep Power
- 0
Hello Norm, I have been reading and found out how to make polygons, right now i am making a house. Which I only have the ceiling, but i have another problem. I make a triangle, and a rectangle to make the ceiling, but the polygon i used to complete the ceiling made 2 tringles instead of 1. Here is the code(I leave some space on the top to make a sun and clouds later on):
Java Code:import java.awt.*; import java.applet.*; public class GUILab extends Applet{ public void paint(Graphics g){ House casa=new House(g); } } class House{ public House(Graphics g){ Tri(g); Tech(g); } public void Tri(Graphics g){ Polygon tri=new Polygon(); tri.addPoint(200, 250); tri.addPoint(125, 400); tri.addPoint(275, 400); g.setColor(Color.blue); g.fillPolygon(tri); } public void Tech(Graphics g){ Polygon tech=new Polygon(); tech.addPoint(200, 250); tech.addPoint(275, 400); tech.addPoint(450, 250); tech.addPoint(450, 400); g.setColor(Color.red); g.fillPolygon(tech); } }
- 10-05-2010, 02:29 AM #4
How did you put together the points that you are trying to draw? You need to take a piece of paper and write down the points in the order you want them and then transpose them into your program.
- 10-05-2010, 02:31 AM #5
Member
- Join Date
- Jul 2010
- Posts
- 27
- Rep Power
- 0
That's what I did, but idk why it does that, did u run it to saw the problem?
- 10-05-2010, 02:35 AM #6
Try redesigning/changing the polygon points to be the shape you want.
- 10-05-2010, 02:47 AM #7
Member
- Join Date
- Jul 2010
- Posts
- 27
- Rep Power
- 0
Now it works thanks.
Java Code:import java.awt.*; import java.applet.*; public class GUILab extends Applet{ public void paint(Graphics g){ House casa=new House(g); } } class House{ public House(Graphics g){ Tech(g); Tri(g); } public void Tri(Graphics g){ Polygon tri=new Polygon(); tri.addPoint(200, 250); tri.addPoint(125, 400); tri.addPoint(275, 400); g.setColor(Color.blue); g.fillPolygon(tri); } public void Tech(Graphics g){ g.setColor(Color.red); g.fillRect(200, 250, 250, 150); } }
Similar Threads
-
How to use graphics
By Mattedatten in forum New To JavaReplies: 3Last Post: 03-18-2010, 02:10 PM -
New simple application using a simple database
By webbusiness23 in forum New To JavaReplies: 9Last Post: 08-03-2009, 02:55 AM -
Help with a very simple method for a very simple beginner.
By cakeman in forum New To JavaReplies: 2Last Post: 05-04-2008, 05:27 PM -
graphics
By Joe2003 in forum Advanced JavaReplies: 4Last Post: 01-18-2008, 07:44 PM -
Graphics
By feniger in forum New To JavaReplies: 1Last Post: 12-29-2007, 04:22 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks