Results 1 to 5 of 5
  1. #1
    joker600 is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Please help me in this graphic!

    Help please!
    I need a code that draw this graphic ...

    Please help me in this graphic!-p1.jpg
    Last edited by joker600; 11-23-2012 at 12:48 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Please help me in this graphic!

    This is a forum, not a code factory. Go through the tutorials and try it yourself, then if you have a specific question about your code you can ask it here.

    Trail: 2D Graphics (The Java™ Tutorials)
    Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    How to ask questions the smart way

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    joker600 is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Please help me in this graphic!

    I want to write a code that draw this graphic



    The code must be build using the following algorithms

    Java Code:
    	void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
    
    	int dx = x2 - x1;
    	int dy = y2 - y1;
    	putPixel(g, x1, y1);
            
    	if (Math.abs(dx) > Math.abs(dy)) {
     		float m = (float) dy / (float) dx;
    		float b = y1 - m*x1;
     		dx = (dx < 0) ? -1 : 1;
    
    		while (x1 != x2) {
     			x1 += dx;
    			putPixel(g, x1, Math.round(m*x1 + b));
    		}
    	} else	if (dy != 0) {
    		float m = (float) dx / (float) dy;
    		float b = x1 - m*y1;
    		dy = (dy < 0) ? -1 : 1;
    		while (y1 != y1) {
    			y1 += dy;
    			putPixel(g, Math.round(m*y1 + b), y1);
    		}
    	}
            
    		g.setColor(Color.black);
    		g.drawLine(x1 * pixelSize, y1 * pixelSize, x2 * pixelSize, y2
    				* pixelSize);
    
    	}
    Java Code:
    	void drawCircle(Graphics g,int xCenter , int yCenter , int radius){
                 
    	int x, y=0, r2;
            
            r2 = radius * radius;
            for (x = -radius; x <= radius; x++) {
                y = (int) (Math.sqrt(r2 - x*x) + 0.5);
                putPixel(g, xCenter + x, yCenter + y);
                putPixel(g, xCenter + x, yCenter - y);
            }    
            
    		g.setColor(Color.black);
    		g.drawOval(xCenter, yCenter, r2, r2);
    	
            }
    Honestly I don't know where to start,, any help please!

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Please help me in this graphic!

    Please go through the Forum Rules -- especially the second paragraph. Don't start a new thread every time you have a follow-on question.

    Moreover, it's rude to ask another question without having first replied to responses on any earlier thread. I've merged the new thread here.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    joker600 is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Re: Please help me in this graphic!

    I cannot edit on the first post! so I wanted to remove it (but I can't do that either!) to start new one showing the code I've tried to wrote (because you told me to try something)
    Now I'm thinking of leaving the whole forum,, because nothing is work

Similar Threads

  1. I need help with Graphics
    By Wizard0860 in forum New To Java
    Replies: 2
    Last Post: 11-17-2012, 10:05 AM
  2. SVG graphics
    By Lacrim in forum Advanced Java
    Replies: 2
    Last Post: 06-09-2012, 01:54 AM
  3. Graphics 2D
    By scopene in forum Java 2D
    Replies: 0
    Last Post: 03-26-2012, 02:21 AM
  4. Drawing a graphics onto another Graphics ?
    By Ziden in forum Java Applets
    Replies: 0
    Last Post: 01-08-2011, 08:30 PM
  5. Help me with graphics
    By 7oclock in forum New To Java
    Replies: 12
    Last Post: 04-05-2009, 12:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •