Please help me understand blend()
in
Programming Questions
•
11 months ago
Hello again. I'm not sure if I'm doing this incorrectly or if it's a different problem. I've been trying to use blend() but it doesn't seem to be blending as expected. I have a background image and a greyscale image that I'd like blended on top of that. I've taken to putting one image offscreen because I couldn't work out any other way to not have the target and source be the same, and thus the blended image gets lost in the original. Tell me how far off the road I am, please! How do I do this properly and see the same effects as seen on the demo page? (
http://www.processing.org/reference/blend_.html)
- PImage planetBack, planetShadow;
- void setup() {
- size(1280, 720, OPENGL);
- smooth();
- planetBack = loadImage("PlanetBackPixel.png");
- planetShadow = loadImage("planetShadow.png");
- shadowBuffer = createGraphics(planetShadow.width, planetShadow.height);
- imageMode(CORNER);
- background(0);
- image(planetShadow, 0, 0);
- shadowBuffer.beginDraw();
- shadowBuffer.blend(planetShadow, 0, 0, shadowBuffer.width, shadowBuffer.height, 0, 0, shadowBuffer.width, shadowBuffer.height, HARD_LIGHT);
- shadowBuffer.endDraw();
- }
- void draw() {
- tint(planetHue, 200, 255);
- image(planetBack, 0, 0);
- rotate(radians(sunPosition));
- tint(planetHue, 100, 255);
- image(shadowBuffer, 0, 0);
- noTint();
- }
1