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.
IndexSuggestions & BugsSoftware Bugs › tint color on an image
Page Index Toggle Pages: 1
tint color on an image (Read 2278 times)
tint color on an image
Apr 3rd, 2007, 3:43am
 
Hi,
I have tried something like

1)
void setup()
{
 ...
 size(400,400);
 ...
}
void draw()
{
 ...
 tint(color(255,0,0));
 rotateX(0.1);
 image(img,0,0);
 ...
}
The rotateX causes a compiling error due to it's only supported by P3D and OPENGL, then

2)
void setup()
{
 ...
 size(400,400,P3D);
 ...
}
void draw()
{
 ...
 tint(color(255,0,0));
 rotateX(0.1);
 image(img,0,0);
 ...
}
I found there is no way I could tint with red color on the image.Then I tried

3)
void setup()
{
 ...
 size(400,400,OPENGL);
 ...
}
void draw()
{
 ...
 tint(color(255,0,0));
 rotateX(0.1);
 image(img,0,0);
 ...
}
There is nothing.

So What can I do???
Re: tint color on an image
Reply #1 - Apr 3rd, 2007, 9:42am
 
have you tried

tint(255,0,0) instead?

I don't think you need to pass a color object inside tint.
Re: tint color on an image
Reply #2 - Apr 3rd, 2007, 11:01am
 
Syntax tint(gray)
tint(gray, alpha)
tint(value1, value2, value3)
tint(value1, value2, value3, alpha)
tint(color)
tint(color, alpha)
tint(hex)
tint(hex, alpha)
Re: tint color on an image
Reply #3 - Apr 11th, 2007, 5:20am
 
In short, the tint does not work on image in P3D or OPENGL mode.
Anyone has any idea?
Re: tint color on an image
Reply #4 - Apr 11th, 2007, 5:22pm
 
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1122315610
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1163449259
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1172789679
Re: tint color on an image
Reply #5 - Apr 11th, 2007, 8:09pm
 
Here's a "hack" that sort of points out the culprit and provides a work around of sorts (though NOT fully compatible):

Quote:


PImage img;

void setup() {
 size(200,200,P3D);
 img = loadImage("milan_rubbish.jpg");
}

void draw() {
 tint(color(255,0,0));
 rotateZ(0.1);
//  image(img,0,0); // won't tint
 hacked_image(img,0,0); // will tint
}

// a hacked version of image(PImage,float,float) from PGraphics:
// (note: this is NOT a complete solution, like it doesn't support
//  imageMode(CORNERS) and so forth, just a quick hack to "expose" the problem)
void hacked_image(PImage image, float x, float y) {
 float x1 = x;
 float x2 = x + image.width;
 float y1 = y;
 float y2 = y + image.height;
 float u1 = 0;
 float v1 = 0;
 float u2 = image.width;
 float v2 = image.height;
 
 boolean savedStroke = g.stroke;
 g.stroke = false;

 color savedFillColor = g.fillColor;
 color savedTintColor = g.tintColor;
 
 // some "slightly" different color
 color alterTintColor = color(red(savedTintColor)-1, green(savedTintColor), blue(savedTintColor), alpha(savedTintColor));  
 
 beginShape(QUADS);
 texture(image);
 // HOW THE HACK WORKS:
 // normally P3D won't tint a flat-shaded textured triangle
 // (it will take the alpha from the tint, but not the rgb)
 // so by slightly varying the fill on vertexes it forces the triangle renderer
 // to use gourard shading thus tinting the texture as expected (more or less)
 fill(alterTintColor);  vertex(x1, y1, u1, v1);
 fill(savedTintColor);  vertex(x1, y2, u1, v2);
 fill(alterTintColor);  vertex(x2, y2, u2, v2);
 fill(savedTintColor);  vertex(x2, y1, u2, v1);
 endShape();

 // restore stuff we've messed with:  
 fill(savedFillColor);
 g.stroke = savedStroke;
}

Re: tint color on an image
Reply #6 - Apr 12th, 2007, 2:57am
 
Thx, I will try and see the performance; it seems there are lots of calculation.

The issue reported on Jul 25th, 2005, and I don't think it could be fixed in the near future. I think I need to adopt the altenative solution.
Page Index Toggle Pages: 1