Re: Scintilla Colours

From: Date: Thu, 30 Jan 2003 04:36:50 +0000
Subject: Re: Scintilla Colours
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2991@lists.php.net to get a copy of this message
Cheers for the help. I made a function up which converts a full hash string to the correct integer: function hex_int ($hex_string) { $hex_string=str_replace ("#", "", $hex_string); $rgb=chunk_split($hex_string, 2, "|"); list($r, $g, $b)=explode("|", $rgb); $rgb_rev=$b.$g.$r; $result=hexdec($rgb_rev); return $result; } If the method took in a full hash string instead of an integer it would save everyone alot of time im sure :) Steph wrote: > Yeah, I went there too. > Basically at the point of collection the 'amount of > redness/greenness/blueness' comes back expressed as a > float/double/percentage (whichever you love best). So from an elderly > colourwheel: > if($cs->get_color() !== array(1.0, 1.0, 1.0, 1.0)) { > $newcolourparts = $cs->get_color(); > $part1 = $newcolourparts[0]; > echo $part1."n"; > $rr = dechex ($part1*255); > echo $rr."n"; > $part2 = $newcolourparts[1]; > $gg = dechex ($part2*255); > $part3 = $newcolourparts[2]; > $bb = dechex ($part3*255); > } > - where the entire hex colour value is #f5ff5e, this prints: > 0.96205214893657 > f5 > with the 'missing link' being the decimal 255 * 0.96205214893657 > (245.32329797882535, which probably comes close to the kind of value > you're looking for) > hth, I know it's a mucky subject .. > ----- Original Message ----- > From: "Aaron Bishell" <aragorn@gamer.net.nz> > To: <php-gtk-general@lists.php.net> > Sent: Thursday, January 30, 2003 2:55 AM > Subject: [PHP-GTK] Scintilla Colours > > Using methods such as "set_sel_fore" on a scintilla widget demands > that > > the second argument be an integer representing the colour. > > > > I went to the scintilla homepage here: > > http://www.scintilla.org/ScintillaDoc.html#colour > > > > And it says: > > > > Colours are set using the RGB format (Red, Green, Blue). The intensity > of > > each colour is set in the range 0 to 255. If you have three such > > intensities, they are combined as: red | (green << 8) | (blue << 16). > > > > I know the << operator is a binary shift operator but I don't know > exactly > > how it works in terms of decimal numbers. > > > > Basically id like an example of how to convert three RGB numbers (e.g. > > R:10, G:36, B:106) to this integer equivalent. I had a look through > > PHPmole and all the settings are in the integer form so not much help. > > > > Any help appreciated. > > > > > > -- > > PHP-GTK General Mailing List (http://gtk.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > >

« previous php.gtk.general (#2991) next »