Mask() not available?
in
Programming Questions
•
19 days ago
Hi
I am trying the following code to test mask() using two PGraphics instances. Console displays:
mask() is not available with this renderer
I have no idea why this is not working. Also, if I switch the PGraphics to PImage files and load the images, mask() displays them all wrong - hard edges and lines where they shouldn't be any.
Here is a code example:
- PVector location; // Location of shape
- PVector velocity; // Velocity of shape
- PVector gravity; // Gravity acts at the shape's acceleration
- PFont font;
- PGraphics ball, pg;
- void setup() {
- size(400, 400);
- smooth();
- location = new PVector(100, 100);
- velocity = new PVector(1.5, 2.1);
- gravity = new PVector(0, 0.2);
- font = createFont("ArialMT-48.vlw", 80);
- pg = createGraphics(400, 400);
- ball = createGraphics(400, 400);
- }
- void draw() {
- background(0);
- pg.beginDraw();
- pg.smooth();
- pg.textFont(font);
- pg.fill(255,0,0);
- pg.text("TESTING", 30, 150, pg.width, pg.height);
- pg.endDraw();
- location.add(velocity);
- velocity.add(gravity);
- if ((location.x > width) || (location.x < 0)) {
- velocity.x = velocity.x * -1;
- }
- if (location.y > height) {
- velocity.y = velocity.y * -0.95;
- location.y = height;
- }
- ball.beginDraw();
- ball.noStroke();
- ball.background(0);
- ball.fill(255);
- ball.ellipse(location.x, location.y, 100, 100);
- ball.endDraw();
- ball.filter(GRAY);
- ball.mask(pg);
- image(pg, 0, 0);
- }
1