Results 1 to 6 of 6

Thread: Getting random color from the Color class?

  1. #1

    Thread Starter
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281

    Getting random color from the Color class?

    I'd like to know how to do this with --any class that has various values to choose from.


    thanks. anything will help.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    How about this:

    VB Code:
    1. Dim intRandRed As Integer, intRandGreen As Integer, intRandBlue As Integer
    2.  
    3.         Randomize()
    4.         intRandRed = Int((256) * Rnd())
    5.         Randomize()
    6.         intRandGreen = Int((256) * Rnd())
    7.         Randomize()
    8.         intRandBlue = Int((256) * Rnd())
    9.  
    10.  
    11.         System.Drawing.Color.FromArgb(intRandRed, intRandGreen, intRandBlue)

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Naughty froggy. There is no need to put Randomize 3 times, just the once will do, at the top.
    I don't live here any more.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by wossname
    Naughty froggy. There is no need to put Randomize 3 times, just the once will do, at the top.
    I wanted it to be as random as possible!

  5. #5

    Thread Starter
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281
    works wonders
    I didn't know about that function =/

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Originally posted by mendhak
    I wanted it to be as random as possible!
    Then why didn't you use the Cryptographically strong randomizer? (System.Security.Cryptography, I think) That even gives output as byte values!

    Very naughty froggy
    I don't live here any more.

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