Results 1 to 6 of 6

Thread: How do i draw a line without using direct draw??

  1. #1

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460

    Question

    I got the x and y coordinates of the pointer. How can i draw a line with that coordinates. I can´t use Direct draw ( sitting on a NT station). I have some idea of catching the movement in shootergames like Q3. Then i can compare it to other gamers. Good idea? Yeeeah!

  2. #2
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Talking

    Assuming you have a Picture Box on your form:

    Code:
    Private Sub Picture1_Click()
    Picture1.Scale (-10, 10)-(10, -10)
    
        'Draw the X and Y Axis
        Picture1.Line (0, -10)-(0, 10), QBColor(9)
        Picture1.Line (-10, 0)-(10, 0), QBColor(12)
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460

    Unhappy

    The code u sent was creating a cross, thats good. But i´m not that good. Pleease specify! I have the x and y coordinates in pixels and i want to draw a line between each of this point. It is thousands of points.

  4. #4
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Angry

    It did not create a cross, it created two lines one vertical
    and one horizontal. The fact that they intersect in the middle of the picture box is a function of their x and y coordinates.
    Code:
    Picture1.Scale (-10, 10)-(10, -10)
        
    'the syntax is Object.Line (x1, y1) - (x2, y2)
    'where x1,y1 are the coordinates to start and x2,y2 are the
    'final coordinates, so the following draws a horizontal line
    'because x1 & y1 both equal zero
    Picture1.Line (0, -10)-(0, 10), QBColor(9)
    
    'and the following draws the vertical line
    'it is centered because x2 and y2 are zero
    Picture1.Line (-10, 0)-(10, 0), QBColor(12)
    The Line Command only connects two points, to continue the line
    to the next set of points the last set of the previous becomes the
    first set of the next and so forth;

    To draw a single line through a number of points you would have
    to define the line or curve in the form of an equation and use the
    Pset Method which in essence connects the dots defined by your x and y points.


    Code:
     For X = -10 To 20 Step 0.001
        
            'Equation to Graph
            Y = 2 * X ^ 2 + 5 * X - 4
            Picture1.PSet (X, Y), QBColor(12) 'draw the dots
    
        Next
    Good Luck


  5. #5

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460

    Wink

    Sorry!! I´ve got a bad day. I will try the code and come back to you. Thanx...

  6. #6

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460

    Thumbs up

    Thank u! I got it now! Yessss!!

Posting Permissions

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



Click Here to Expand Forum to Full Width