eleria Posted May 28, 2008 Posted May 28, 2008 (edited) 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 expandcollapse popupdim $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 May 28, 2008 by eleria
GHOSTSKIKDA Posted May 29, 2008 Posted May 29, 2008 Hi! I don't think sow !!!!!!! [center]I LOVE ALGERIA .... ;-)[/center]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now