We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
PImage.tint() (Read 1568 times)
PImage.tint()
Nov 12th, 2007, 10:17pm
 
right now, i'm tint() before all my PImages inorder to add alpha to PImage, but this is inefficient since i have to do it for EVERY PImage

this might exist and I'm just blind, but

tinting the specific image would be helpful, like the .filter command or .blend()

.tint would be great
Re: PImage.tint()
Reply #1 - Nov 14th, 2007, 3:36am
 
You should just use tint() method. I didn't even know PImage had a tint itself.

tint(255,80);

// draw all your images

noTint(); // to stop tinting
Re: PImage.tint()
Reply #2 - Nov 15th, 2007, 5:19am
 
it doesn't. i'm saying there should be

the problem comes, what if you want to tint 100 different images to each individual tint

then it's better to have specific tint for each PImage instead of doing

tint
image
tint
image
tint
image
Re: PImage.tint()
Reply #3 - Nov 15th, 2007, 5:20am
 
i mean, would be so much simpler to have .tint for images

that way, if only half of the things you need to tint
then you don't have to say noTint at the end of the image

yes, i'm saying this to eliminate code, but come on, .tint would be so much more efficient
Re: PImage.tint()
Reply #4 - Nov 15th, 2007, 4:59pm
 
you could just write a wrapper, along the lines of:

void tintImage(PImage img, float x, float y, float r, float g, float b, float a) {
 tint(r,g,b,a);
 image(img,x,y);
 noTint();
}
Re: PImage.tint()
Reply #5 - Nov 15th, 2007, 8:14pm
 
fwiw, it's unfortunately fairly messy to implement.

1) PGraphics (and PApplet by extension) subclass PImage, so applying tint() would set the regular drawing surface a certain color (or if disabled for PGraphics, would cause inconsistent behavior when people *wanted* to do that, e.g. with a PGraphics from createGraphics).

2) the colorMode() setting is needed for all color functions, and it lives in PGraphics, not PImage. moving all the mode functions to PImage would be yucky.

3) filter(TINT, colorInt) would be an option, but would require a version of filter() that takes an int as a second parameter, and would join lerpColor() as the only color-related function in the api that only supports colors as the int (or 'color') data type.

4) note that doing this would be a destructive operation. so it would certainly save some speed when used with some renderers (actually, prolly only JAVA2D), you wouldn't be able to change the tint "back", which is likely to cause some degree of confusion (though less so with the filter() option).
Page Index Toggle Pages: 1