mIRC Home    About    Download    Register    News    Help

Print Thread
#177979 03/06/07 07:19 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
how do i convert red to hex format?
red rgb is $rgb(255)

how to convert to FF0000 ?

pouncer #177980 03/06/07 07:33 PM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
Code:
alias test echo -a $hexrgb(255)
alias hexrgb {
  var %a = $base($gettok($rgb($1), 1, 44), 10, 16)
  var %b = $base($gettok($rgb($1), 2, 44), 10, 16)
  var %c = $base($gettok($rgb($1), 3, 44), 10, 16)
  return $+(%a, %b %c)
}

Last edited by NaquadaServ; 03/06/07 07:33 PM.

NaquadaBomb
www.mirc-dll.com
NaquadaServ #177981 03/06/07 07:39 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Thanks for the reply and code bud.

but it echos

FF0 0

:s

pouncer #177983 03/06/07 07:53 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Code:
alias hexrgb { 
  tokenize 44 $iif($0 > 1,$+($calc($1),$chr(44),$calc($2),$chr(44),$calc($3)),$rgb($1))
  return $base($rgb($3,$2,$1),10,16,6)
}

That will work for both $hexrgb(16777215) and $hexrgb(255,255,255) inputs.

pouncer #177991 03/06/07 09:17 PM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
Code:
alias test echo -a $hexrgb(255)
alias hexrgb {
  var %a = $base($gettok($rgb($1), 1, 44), 10, 16, 2)
  var %b = $base($gettok($rgb($1), 2, 44), 10, 16, 2)
  var %c = $base($gettok($rgb($1), 3, 44), 10, 16, 2)
  return $+(%a, %b %c)
}


NaquadaBomb
www.mirc-dll.com

Link Copied to Clipboard