Background shines through text?
in
Core Library Questions
•
8 months ago
Hi everyone,
I need a little help in Processing color theory and/or overlaying graphics!
In my sketch I have a half transparent text on a separat PGraphics. When I overlay this text onto an other
PGraphics with an opaque rectangle and finally overlay this PGraphics onto the main canvas, the background of the canvas shines through the text.
What I expected was that the half transparent text will be merged with the rectangle color and will get opaque and not that the opaque rectangle gets transparent with the overlayed text. It's as the text works like an alpha mask, but I don't want that.
What do I miss here? Or whats the right way to archive my expected result?
Thank you for your time!
My specs: Windows7 64bit, NVIDIA GeForce 560M, Processing 2.0b6
I need a little help in Processing color theory and/or overlaying graphics!
In my sketch I have a half transparent text on a separat PGraphics. When I overlay this text onto an other
PGraphics with an opaque rectangle and finally overlay this PGraphics onto the main canvas, the background of the canvas shines through the text.
What I expected was that the half transparent text will be merged with the rectangle color and will get opaque and not that the opaque rectangle gets transparent with the overlayed text. It's as the text works like an alpha mask, but I don't want that.
What do I miss here? Or whats the right way to archive my expected result?
Thank you for your time!
My specs: Windows7 64bit, NVIDIA GeForce 560M, Processing 2.0b6
- package spheretest;
- import processing.core.PApplet;
- import processing.core.PGraphics;
- public class Main extends PApplet {
- /**
- *
- */
- private static final long serialVersionUID = 3655653701051264925L;
- private PGraphics pg = null;
- private PGraphics java2d = null;
- public void setup() {
- size(500, 500, P3D);
- pg = createGraphics(width, height, P3D);
- java2d = createGraphics(width, height, JAVA2D);
- java2d.beginDraw();
- java2d.background(0, 0, 0, 0);
- java2d.fill(0,0,0,150);
- java2d.textSize(36);
- java2d.text("Transparent Text", 50, 50);
- java2d.fill(0,0,0,100);
- java2d.textSize(36);
- java2d.text("Transparent Text", 50, 86);
- java2d.fill(0,0,0,50);
- java2d.textSize(36);
- java2d.text("Transparent Text", 50, 122);
- java2d.endDraw();
- }
- public void draw() {
- background(255, 0, 0);
- noStroke();
- fill(0,255,0);
- rect(50, 50, 400, 25);
- pg.beginDraw();
- pg.background(0, 0, 0, 0);
- pg.noStroke();
- pg.fill(255);
- pg.rect(0, 0, 200, 200);
- pg.image(java2d,0,0);
- pg.endDraw();
- image(pg, 0, 0);
- }
- public static void main(String args[]) {
- PApplet.main(new String[] { spheretest.Main.class.getName() });
- }
- }
1