|
Author |
Topic: hex color in fill() ? (Read 1890 times) |
|
lunetta
|
hex color in fill() ?
« on: Apr 4th, 2005, 6:28am » |
|
Hello all when I set the background of the stage, Processing accepts a color in the hex format: background(0x908A1A); When I trill to fill a rect with a similar value, it doesn't work; Is there a painless fast way to convert the hex to a number the fill() would understand?
|
|
|
|
TomC
|
Re: hex color in fill() ?
« Reply #1 on: Apr 4th, 2005, 11:38am » |
|
Use processing's HTML style colour format: Code: Alternatively, try specifying full alpha too: Code: That might work, but I'm not sure.
|
|
|
|
lunetta
|
Re: hex color in fill() ?
« Reply #2 on: Apr 4th, 2005, 7:42pm » |
|
great, I'll try it. thanks!
|
|
|
|
fry
|
Re: hex color in fill() ?
« Reply #3 on: Apr 4th, 2005, 7:50pm » |
|
yup, both of tom's examples should work. the only errant case is if you say fill(0x000000), which will come out as black and opaque (since it's indistinguishable from fill(0)).
|
|
|
|
rgovostes
|
Re: hex color in fill() ?
« Reply #4 on: Apr 4th, 2005, 9:23pm » |
|
Hmm, regarding your last comment, Fry - wouldn't any value up to and including 0xFF be opaque, because it is indistinguishable from doing a grayscale color? This shouldn't just be true for 0.
|
|
|
|
fry
|
Re: hex color in fill() ?
« Reply #5 on: Apr 5th, 2005, 3:56am » |
|
right, if the alpha is zero and it's anything from 0 up to the minimum value (set by colorMode) for the blue, then it defaults to assuming a gray fill. it's not great but it's a minor case and it's the least of a few evils.
|
|
|
|
rgovostes
|
Re: hex color in fill() ?
« Reply #6 on: Apr 6th, 2005, 5:08am » |
|
Then one would think that a blue maximum value of 2,147,483,647 would make it impossible to set any color? Not that anything like that would happen! Thanks for clarifying how the mechanism works.
|
|
|
|
fry
|
Re: hex color in fill() ?
« Reply #7 on: Apr 6th, 2005, 6:46am » |
|
hm, i suppose.. but i think you'd run into far worse problems if you set the max value for blue that high.
|
|
|
|
|