Results 1 to 7 of 7

Thread: SetPixel() : An Interesting Example

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    SetPixel() : An Interesting Example

    Enclosed is an example of using SetPixel().
    This example, which I like to call 'flies', creates a black picturebox.
    Then once you click inside the PictureBox, it will create what looks like lots of flies.
    When you move the mouse cursor around they try to get away from the cursor.
    I think it looks quite nice

    If you have any queries or comments, just let me know.
    Attached Files Attached Files
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    * 21-October-2004 - Moved to CodeBank *
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Just spent 10 minutes messing with it.

    (the program that is)
    I don't live here any more.

  4. #4

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Actually I forgot what that app did. God that is so much fun
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5
    Addicted Member kill_bill_gates's Avatar
    Join Date
    Oct 2004
    Posts
    222


    great app. really funny
    "Quis custodiet ipsos custodes?"
    Juvenal
    Mete the Hun wanted to live in peace with the Chinese. So he gave the Chinese Emperor his favorite horse, best swords in his armory, and lots of other cool stuff. But then the Chinese Emperor asked for one thing. A useless land through the north. It was a small, useless, unproductive, uninhabited piece of land. But Mete the Hun's answer was certain:
    I gave you horses, weapons and much more which belonged to me. But the lands are not mine, it's my nation's and I'm ready to fight, kill and die for just an inch my country
    -=Joey Jordison R0CKS!! =-

  6. #6
    Member
    Join Date
    Mar 2004
    Location
    INDIA
    Posts
    36

    area around cursor

    hi

    great prog
    i tried to change the area around the cursor to a box but it still behaves like as if it was a circle???

    onil

    also at

    onil67@hotmail.com

  7. #7

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    The flies' positions are goverened by this:

    VB Code:
    1. For i = 0 To UBound(pixels) - 1
    2.         With pixels(i)
    3.             ''
    4.             '' some code
    5.             ''
    6.             If distanceBetweenTwoPoints(pos, .pos) < 25 Then
    7.                 Do Until (distanceBetweenTwoPoints(pos, .pos) > 35)
    8.                     With .pos
    9.                         .x = .x + (2 * Rnd)
    10.                         .Y = .Y + (2 * Rnd)
    11.                     End With
    12.                 Loop
    13.             End If
    14.             ''
    15.             '' some code
    16.             ''
    17.     Next
    18.  
    19.     ''
    20.     '' elsewhere
    21.     ''
    22. Private Function distanceBetweenTwoPoints(ByRef point1 As pointapi, ByRef point2 As pointapi) As Single
    23.     distanceBetweenTwoPoints = (((point2.x - point1.x) ^ 2) + ((point2.Y - point1.Y) ^ 2)) ^ 0.5
    24. End Function
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

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