Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Obtaining straightline pixels

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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...


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Obtaining straightline pixels

    Is this a Math question or Java question?

    The equation for a straight line is
    y-y1 = m(x-x1)
    where m = gradient
    m = (y2-y1)/(x2-x1)

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Obtaining straightline pixels

    i want the java code to get the all pixel values of the straigt line....can you help me please...

  4. #4
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Obtaining straightline pixels

    No. You need to do something first, I'm not going to do everything just for you to turn around and go thats not what im after.

  5. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Obtaining straightline pixels

    Java Graphics class
    use the drawLine method.