Results 1 to 3 of 3
  1. #1
    base2coder is offline Member
    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0

    Default Obtaining straightline pixels

    I have two coordinates like (x1,y1) and (x2,y2). now i want to draw a straight line between them and want to get all the pixels on it. how can i do it?? can anyone help me please...:confused::confused:

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    Java Code:
    //in a custom JPanel
    public void paintComponent(Graphics g)
    {
       super.paintComponent(g);
    
       g.drawLine(x1,y1,x2,y2); 
    }
    the second part of your question is algebra: y = mx + b
    My Hobby Project: LegacyClone

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. Obtaining relative path outside of executable JAR
    By tjsaker in forum Advanced Java
    Replies: 1
    Last Post: 11-14-2008, 06:48 AM
  2. HashMap: Obtaining all values in a collision?
    By markus-sukram in forum New To Java
    Replies: 2
    Last Post: 03-29-2008, 10:25 PM
  3. Blurring pixels
    By tim in forum New To Java
    Replies: 0
    Last Post: 01-01-2008, 02:06 PM
  4. Counting Pixels
    By shaungoater in forum Java 2D
    Replies: 5
    Last Post: 11-29-2007, 05:51 PM
  5. Replies: 1
    Last Post: 11-16-2007, 10:09 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
  •