well here's the
hashing function:
CODE
// the string to be hashed
$puts(KEY,%album%)
// seed value for the hash
// changing this should give you radically different results
// seeding with $rand() might be useful
$puts(HASH,3)
// assigns a numerical value to each letter
// should expand fine if other characters are needed
$puts(COVA,1)
$puts(COVB,2)
$puts(COVC,3)
$puts(COVD,4)
$puts(COVE,5)
$puts(COVF,6)
$puts(COVG,7)
$puts(COVH,8)
$puts(COVI,9)
$puts(COVY,10)
$puts(COVJ,11)
$puts(COVK,12)
$puts(COVL,13)
$puts(COVM,14)
$puts(COVN,15)
$puts(COVO,16)
$puts(COVP,17)
$puts(COVQ,18)
$puts(COVR,19)
$puts(COVS,20)
$puts(COVT,21)
$puts(COVU,22)
$puts(COVV,23)
$puts(COVW,24)
$puts(COVX,25)
$puts(COVZ,26)
// pointer to current character
$puts(POS,0)
// each line adds one more character to the hash
// function: HASH += HASH*KEY[POS]
// fell free to come up with a better hash function I just made this one up
$puts(HASH,$add($get(HASH),$mul($get(HASH),$get(COV$upper($substr($get(KEY),$put(POS,$add(1,$get(POS))),$get(POS)))))))
$puts(HASH,$add($get(HASH),$mul($get(HASH),$get(COV$upper($substr($get(KEY),$put(POS,$add(1,$get(POS))),$get(POS)))))))
$puts(HASH,$add($get(HASH),$mul($get(HASH),$get(COV$upper($substr($get(KEY),$put(POS,$add(1,$get(POS))),$get(POS)))))))
$puts(HASH,$add($get(HASH),$mul($get(HASH),$get(COV$upper($substr($get(KEY),$put(POS,$add(1,$get(POS))),$get(POS)))))))
$puts(HASH,$add($get(HASH),$mul($get(HASH),$get(COV$upper($substr($get(KEY),$put(POS,$add(1,$get(POS))),$get(POS)))))))
$puts(HASH,$add($get(HASH),$mul($get(HASH),$get(COV$upper($substr($get(KEY),$put(POS,$add(1,$get(POS))),$get(POS)))))))
$puts(HASH,$add($get(HASH),$mul($get(HASH),$get(COV$upper($substr($get(KEY),$put(POS,$add(1,$get(POS))),$get(POS)))))))
$puts(HASH,$add($get(HASH),$mul($get(HASH),$get(COV$upper($substr($get(KEY),$put(POS,$add(1,$get(POS))),$get(POS)))))))
// $hex doesn't like negative numbers so take the absolute value
$puts(HASH,$replace($get(HASH),-,))
// remap the hash function into a colour code
$hex($mod($get(HASH),16777213),6)
Basically this will assign a random number to any unique string. Usage so far is to create a unique colour for every album or use it in a sorting string to enable a random album playback, fell free to come up with more ways to use it.
BONUS function,
HSV->RGB conversion:
CODE
// S between 0 and 255
$puts(S,56)
// V between 0 and 255
$puts(V,128)
// H between 0 and 360
$puts(H,325)
$if($strcmp($get(S),0),$puts(R,$get(V))$puts(G,$get(V))$puts(B,$get(V)),
//else
$puts(I,$div($get(H),60))
$puts(F,$sub($div($mul($get(H),1000),60),$mul($div($get(H),60),1000)))
$puts(P,$div($mul($get(V),$sub(256,$get(S))),256))
$puts(Q,$div($mul($get(V),$sub(256,$div($mul($get(S),$get(F)),1000))),256))
$puts(T,$div($mul($get(V),$sub(256,$div($mul($get(S),$sub(1,$get(F))),1000))),256))
$if($strcmp($get(I),0),$puts(R,$get(V))$puts(G,$get(T))$puts(B,$get(P)),
$if($strcmp($get(I),1),$puts(R,$get(Q))$puts(G,$get(V))$puts(B,$get(P)),
$if($strcmp($get(I),2),$puts(R,$get(P))$puts(G,$get(V))$puts(B,$get(T)),
$if($strcmp($get(I),3),$puts(R,$get(P))$puts(G,$get(Q))$puts(B,$get(V)),
$if($strcmp($get(I),4),$puts(R,$get(T))$puts(G,$get(P))$puts(B,$get(V)),
$puts(R,$get(V))$puts(G,$get(P))$puts(B,$get(Q)))))))
)
$puts(R,$hex($get(R),2))
$puts(G,$hex($get(G),2))
$puts(B,$hex($get(B),2))
$get(B)$get(G)$get(R)
Basically the same as Canar's coverter except using HSV instead of HSL. I don't use colour codes much (at all) so I don't know what the difference is or if this even really works as it should (I just transcribed some c code I found) so use at your own risk.
Both these functions can also be found in
this thread.
I also have a function that come up with a gradated colour based on byterate, but I think $transition has made that obsolete so I won't include that here.