Jump to content
Sign in to follow this  
eleria

Color generator script (tweakable)

Recommended Posts

eleria

Hi guys today I found out that I needed a way to generate BGR colors randomly.

And didn't find any script of the sort...

Then I thought that not only must they be random, but ever color must be unique AND must have a value which differ by a fixed ammount from the others...

Not sure if that was understandable, but I think code will be clearer :)

dim $max = 150

;Keep the same value for all 3 unless you use an AND check
dim $gapB=35, $gapG=35, $gapR=35


dim $minB = 25, $minG = 25, $minR = 25
dim $maxB=255, $maxG = 255, $MaxR=255

Dim $seedB, $count, $count2, $seedG, $seedB, $saveB[$max+1], $saveG[$max+1], $saveR[$max+1]
For $count = 1 To 150
    While 1
        $count2 = 1
        $seedB = Random($minB, $maxB, 1)
        $seedG = Random($minG, $maxG, 1)
        $seedR = Random($minR, $maxR, 1)
        switch $count = 1 
            Case 1
            $saveB[$count] = $seedB
            $saveG[$count] = $seedG
            $saveR[$count] = $seedR
        Endswitch
        While Not ($count2 = $count)
            Switch (Abs($seedB - $saveB[$count2]) > 35) Or (Abs($seedG - $saveG[$count2]) > 35) Or (Abs($seedR - $saveR[$count2]) > 35)
                Case 1
                    $count2 += 1
                Case Else
                    ExitLoop
            EndSwitch
        WEnd
        Switch $count2 = $count
            Case 1
                ExitLoop
        EndSwitch
    WEnd
    $saveB[$count] = $seedB
    $saveG[$count] = $seedG
    $saveR[$count] = $seedR
    ConsoleWrite("B=" & $saveB[$count] & " / " & "G=" & $saveG[$count] & " / " & "R=" & $saveR[$count] & @CRLF)
Next

I'd be glad to have some Autoit divinity look at this code and improve it if possible ^^"

Edited by eleria

Share this post


Link to post
Share on other sites
GHOSTSKIKDA

Hi!

I don't think sow !!!!!!!


[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.