When I use PGraphics, there is a strange overlap

LYYLYY
edited May 2018 in Questions about Code

Capture

Answers

  • LYYLYY
    edited May 2018

    Here is its program that can be run directly,No statement indicates that there will be traces outside PGraphics pg.

    PGraphics pg;
    
    void setup() {
      size(640, 360);
      pg = createGraphics(400, 200);
    }
    
    void draw() {
      fill(0, 12);
      rect(0, 0, width, height);
      fill(255);
      noStroke();
      ellipse(mouseX, mouseY, 60, 60);
    
      pg.beginDraw();
      pg.background(51);
      pg.noFill();
      pg.stroke(255);
      pg.ellipse(mouseX-120, mouseY-60, 60, 60);
      pg.endDraw();
    
      // Draw the offscreen buffer to the screen with image() 
      image(pg, 120, 60); 
    }
    
  • there will be traces outside PGraphics pg

    What do you mean? You are drawing a normal ellipse at the mouse coordinates on the line after noStroke. That will of course create traces outside pg

    Also, because you never call background() the main sketch window never complete clears -- you are using repeatedly applying a very low alpha black text.

Sign In or Register to comment.