FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Bug Fixes, Implemented Suggestions
(Moderator: fry)
   gray() like color()?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: gray() like color()?  (Read 2067 times)
narain


gray() like color()?
« on: Jul 18th, 2004, 8:45am »

I'm not sure of the current status of the int vs. color issue (ie. how to differentiate whether an int passed is a gray value or an encoded color), but I came up with something that might help...
 
Why not have a function gray() that takes one int and returns a color?
ie. gray(x) would return color(x,x,x), ie. the integer ff,xx,xx,xx in hex.
 
Then to pass grey values into functions that require colors, users would pass grey(value) instead of the value itself. Thus you no longer need the hack(?) that does checking the high bits etc, because you're not going to get pure unencoded integers.
 
If the problem is resolved otherwise, this could still help code readability:
compare background(gray(50)) with just background(50) or background(color(50,50,50)).
 
fry


WWW
Re: gray() like color()?
« Reply #1 on: Jul 18th, 2004, 4:18pm »

we're actually just gonna have color(50) and color(40, 120) work just like fill(50) and fill(40, 120) so you'll be able to do the gray levels. it's already complete for rev 70.
 
i agree that gray() might help readability in some places, though i think it would break symmetry with the other functions--i.e. fill(gray(40)) seems odd (and unnecessary). and color(40, 40, 40) would return a gray, which seems confusing too. we've been trying to document things in terms of stroke and fill "colors" and to add "grays" which were a subset of that, might be kinda weird.
 
at any rate, hopefully the new color functions will help get you set.
« Last Edit: Jul 18th, 2004, 4:22pm by fry »  
narain


Re: gray() like color()?
« Reply #2 on: Jul 18th, 2004, 6:35pm »

Personally I think four overloaded versions of color() with one, two, three and four arguments are just as confusing... but oh well.
 
So rev 70 == megabucket?
 
fry


WWW
Re: gray() like color()?
« Reply #3 on: Jul 18th, 2004, 7:03pm »

yeah, this is a spot where i don't think there's a perfect solution. fill(40) i think makes fine sense for a gray, but color(40) is admittedly weird, particularly with the alpha. oh well. let's hope it's ok.
 
70 will be megabucket, hopefully. though i should just keep calling it megabucket in case something happens and we have to do a rev 70 before megabucket is ready (as was the case with 68 and 69, and why i started calling it megabucket, as per tomc's (?) suggestion).
 
TomC

WWW
Re: gray() like color()?
« Reply #4 on: Jul 18th, 2004, 7:42pm »

on Jul 18th, 2004, 7:03pm, fry wrote:
i started calling it megabucket, as per tomc's () suggestion).

 
Guilty as charged.
 
Pages: 1 

« Previous topic | Next topic »