Topic: Researching: Generating highlights and lowlights with javascript |
|
---|---|
Author | Thread |
Neurotic (0) Inmate Newly admitted From: |
posted 02-14-2008 01:15
I'm looking for a little advice from anyone who has had experience or knows any examples of programmatically generating highlights and lowlights creating a bevel effect with javascript and css? |
Paranoid (IV) Inmate From: Umeå, Sweden |
posted 02-14-2008 01:20
CSS alone can do that I believe... |
Obsessive-Compulsive (I) Inmate From: |
posted 02-14-2008 01:25
Thanks Liorean... |
Paranoid (IV) Inmate From: Norway |
posted 02-14-2008 01:26 |
Nervous Wreck (II) Inmate From: |
posted 02-14-2008 01:38
Hi poi, |
Paranoid (IV) Inmate From: Norway |
posted 02-14-2008 02:38
then you can use CSS outset border with the border color set to the background color, e.g: code: selector { background-color:orange; border:1px outset orange; } You might need to tweak the dimensions of the element to make sure the border does not affect the box model. code: function getRGB( inputColor ) { var rgb = null; if( '#'==inputColor.charAt(0) ) { // HEX value var tmp = parseInt( inputColor.slice(1), 16 ); if( inputColor.length==4 ) { // short HEX value rgb = { r:(tmp>>8 )*0x11, g:(tmp>>4&15)*0x11, b:(tmp &15)*0x11 } } else if( inputColor.length==7 ) { // long HEX value rgb = { r:tmp>>16&255, g:tmp>> 8&255, b:tmp &255 } } } else if ( 'rgb('==inputColor.slice( 0, 4 ).toLowerCase() ) { // RGB() value var tmp = inputColor.slice( 4, -1 ).split( ',' ); rgb = { r:Math.min( 255, Math.max( 0, Math.round( tmp[0]*1 ) ) ), g:Math.min( 255, Math.max( 0, Math.round( tmp[1]*1 ) ) ), b:Math.min( 255, Math.max( 0, Math.round( tmp[2]*1 ) ) ) } } return rgb; } Then, can crank up/down them all, or compute the HSL and adjust the L at will. |
Paranoid (IV) Inmate From: Umeå, Sweden |
posted 02-14-2008 02:39
Hmm. The square of overlap there is the only thing that isn't easily done with CSS. |
Paranoid (IV) Inmate From: Norway |
posted 02-14-2008 02:43 |
Maniac (V) Mad Librarian From: Seoul, Korea |
posted 02-14-2008 02:56
[Edit: just as I suspected... poi has beaten me to the punch, and with more helpful advice. Feel free to ignore this post.] |
Nervous Wreck (II) Inmate From: |
posted 02-14-2008 03:34
poi and suho... |