PDA

View Full Version : colored text with contrasting colored background



n8huntsman
08-29-2012, 10:30 PM
What is the best way to accomplish this? I can't see to figure it out. I'd like colored text with a contrasting colored background.

chelmuth
08-29-2012, 10:56 PM
a little more detail on your applications

macebobo
08-29-2012, 11:04 PM
If you mean that you want to be able to read the text regardless of the background color, try this:



public static Color getContrastingColor(Color color)
{
int yiq = ((color.R * 299) + (color.G * 587) + (color.B * 114)) / 1000;

return yiq >= 128 ? Color.Black : Color.White;
}


based on YIQ (http://en.wikipedia.org/wiki/YIQ)

This will always allow you to read text regardless of the background color. It is in my Utils class on just about any project dealing with color and text.

n8huntsman
08-29-2012, 11:18 PM
I mean, using Nutcracker text class, I'd like to have a green background and have red text scroll across. I thought there was a way to do it without code or layers but I guess not.

smeighan
08-30-2012, 09:49 AM
I mean, using Nutcracker text class, I'd like to have a green background and have red text scroll across. I thought there was a way to do it without code or layers but I guess not.

create an effect with the color_wash class. Set start and end color to green
create a text effect with text in red, set duration the same as color_wash above

now use the layer effect
1) color_wash
2) text

and choose that effect 2 takes priority over 1.
i created GREEN_BACKGROUND and MERRY_CHRISTMAS effects in your account.
here is result of layer

Effect Settings
username n8huntsman
user_target 5.125_32_STRINGS
effect_class layer
effect_name RED_TEXT_ON_GREEN
layer_method Pri-2
file1 5.125_32_STRINGS+GREEN_BACKGROUND.nc
file2 5.125_32_STRINGS+MERRY_CHRISTMAS.nc
LAYER_EFFECTS Array
lmethod Pri-2
frame_delay 100
seq_duration 10
fade_in 0
fade_out 0
submit Submit Form to create your effect
OBJECT_NAME layer
http://meighan.net/nutcracker/effects/workspaces/39/5.125_32_STRINGS+RED_TEXT_ON_GREEN.gif

RED on GREEN is one of these contrasts that can be hard on the eyes. Maybe darken the green background more?

smeighan
08-30-2012, 11:04 AM
i did one more pass.
darkened green in color_wash and added 20% sparkles (what the heck?)


Effect Settings
username n8huntsman
user_target 5.125_32_STRINGS
effect_class layer
effect_name RED_TEXT_ON_GREEN2
layer_method Pri-2
file1 5.125_32_STRINGS+GREEN_BACKGROUND_SPARKLE.nc
file2 5.125_32_STRINGS+MERRY_CHRISTMAS.nc
LAYER_EFFECTS Array
lmethod Pri-2
frame_delay 100
seq_duration 10
fade_in 0
fade_out 0
submit Submit Form to create your effect
OBJECT_NAME layer
http://meighan.net/nutcracker/effects/workspaces/39/5.125_32_STRINGS+RED_TEXT_ON_GREEN2.gif

macebobo
08-30-2012, 01:45 PM
When I am in my programming mind, I should really read what sub-forum I am in before responding. DOH!


I mean, using Nutcracker text class, I'd like to have a green background and have red text scroll across. I thought there was a way to do it without code or layers but I guess not.

n8huntsman
08-30-2012, 03:48 PM
Awesome. Thanks for the help Sean.