/** * Record individual lines and triangles by echoing them to another renderer. */ public void beginRaw(PGraphics rawGraphics) { // ignore this.raw = rawGraphics; rawGraphics.beginDraw(); }
/** * @nowebref * Begin recording (echoing) commands to the specified PGraphics object. */ public void beginRecord(PGraphics recorder) { this.recorder = recorder; recorder.beginDraw(); }
/** * Record individual lines and triangles by echoing them to another renderer. */ public void beginRaw(PGraphics rawGraphics) { // ignore this.raw = rawGraphics; rawGraphics.beginDraw(); }
/** * Start a new multi-pass rendering with the screen framebuffer. */ public void render() { sketch.g.endDraw(); render(sketch.g); sketch.g.beginDraw(); }
PGraphics image; void setup() { size(500, 500); image = createGraphics(500, 500); image.beginDraw(); for (int i = 0; i < visibleBodies.length; i++) { Body b = visibleBodies[i]; image.point(b.x, -b.z, -b.y); // Z-up world } image.endDraw(); } void draw() { background(255, 0, 0); image(image, 0, 0, width, height); }
PGraphics canvas; size(400,400); //create a PGrahpics layer canvas = createGraphics(width,height); //intialize drawing canvas.beginDraw(); //draw something, pretty similar you'd draw in Processing canvas.background(255); canvas.rect(200,200,150,100); //finish drawing canvas.endDraw(); //PGraphics extends PImage, hence it can drawn as one image(canvas,0,0);
/** * Clear a pass (black with alpha). * * @param pass Pass to clear. */ @Override public void clearPass(PGraphics pass) { // clear pass buffer pass.beginDraw(); pass.background(0, 0); pass.resetShader(); pass.endDraw(); }
PGraphics sharedGraphics; void setup(){ size(500, 500); sharedGraphics = createGraphics(500, 500); } void draw(){ sharedGraphics.beginDraw(); sharedGraphics.background(0); for(int i = 0; i < 10000; i++){ sharedGraphics.ellipse(random(500), random(500), 5, 5); } sharedGraphics.endDraw(); image(sharedGraphics, 0, 0); println(frameRate); }
/** * Compose and finalize rendering. * * @param graphics Texture to render onto. */ @Override public void compose(PGraphics graphics) { clearPass(graphics); graphics.beginDraw(); graphics.image(getCurrentPass(), 0, 0); graphics.endDraw(); }
PGraphics pg; void setup() { size(200, 100); pg = createGraphics(100, 100); } void drawStuff(PGraphics graphics){ graphics.ellipse(50, 50, 25, 25); } void draw() { drawStuff(g); pg.beginDraw(); drawStuff(pg); pg.endDraw(); image(pg, 100, 0); }
PGraphics widg; PVector widgCoord; void setup(){ widgCoord = new PVector(10, 10); widg=createGraphics(50, 50); drawWidg(); image(widg,widgCoord.x, widgCoord.y); } void draw(){ } void mouseClicked(){ if(mouseX > widgCoord.x && mouseX < widgCoord.x + widg.width && mouseY > widgCoord.y && mouseX < widgCoord.y + widg.height){ println("clicked!"); } } void drawWidg(){ widg.beginDraw(); widg.background(255,0,0); widg.endDraw(); }
/** * Start a new multi-pass rendering. * * @param graphics Texture used as input. */ @Override public void render(PImage graphics) { PGraphics pass = getNextPass(); clearPass(pass); pass.beginDraw(); pass.image(graphics, 0, 0); pass.endDraw(); increasePass(); }
PGraphics pdf = new PGraphicsPDF(); pdf.setPrimary(false); pdf.setPath(filename); pdf.setSize(sizeX, sizeY); // pdf.setParent(new PApplet()); This is intentionally NOT called. pdf.beginDraw(); // draw everything pdf.dispose(); pdf.endDraw();
@Override public void apply(Supervisor supervisor) { PGraphics pass = supervisor.getNextPass(); supervisor.clearPass(pass); pass.beginDraw(); pass.shader(shader); pass.image(supervisor.getCurrentPass(), 0, 0); pass.endDraw(); }
PGraphics pg; void setup() { size(200, 200, P2D); pg = createGraphics(100, 100, P3D); } void draw() { pg.beginDraw(); pg.background(0); pg.noStroke(); pg.translate(pg.width*0.5, pg.height*0.5); pg.lights(); pg.sphere(25); pg.endDraw(); background(0, 0, 255); image(pg, 50, 50); }
PGraphics pg; PGraphics pdf; boolean usePdf = false; void setup() { size(100, 100); pg = createGraphics(width, height); pdf = //whatever } void draw(){ if(usePdf){ display(pdf); } else{ display(pg); image(pg, 0, 0); } } void display(PGraphics g) { g.beginDraw(); g.background(100); g.stroke(255); g.line(20, 20, mouseX, mouseY); g.endDraw(); }
public void draw(PGraphics pg, boolean pdf) { pg.beginDraw(); pg.background(WHITE); if (canDraw()) { if (vary.categorical()) { drawEikosogram(pg); } else { drawBoxplot(pg); } } else { drawCross(pg); } if (pdf) pg.dispose(); pg.endDraw(); }
public void draw(PGraphics pg, boolean pdf) { pg.beginDraw(); pg.background(WHITE); if (canDraw()) { float binw = (float)pg.width / binCount; pg.noStroke(); for (int bx = 0; bx < binCount; bx++) { float p = density[bx]; float h = PApplet.map(p, 0, maxProb, 0, 0.5f); // float p = density[bx]; pg.fill(hColor); pg.rect(binw * bx, pg.height * (1 - h), binw, pg.height * h); } } else { drawCross(pg); } if (pdf) pg.dispose(); pg.endDraw(); }
public void draw(PGraphics pg, boolean pdf) { pg.beginDraw(); pg.background(WHITE); if (canDraw()) { float binw = (float)pg.width / binCountX; float binh = (float)pg.height / binCountY; pg.noStroke(); for (int bx = 0; bx < binCountX; bx++) { for (int by = 0; by < binCountY; by++) { float p = PApplet.map(density[bx][by], 0, maxProb, 0, 1); pg.fill(mixColors(WHITE, COLOR, p)); pg.rect(binw * bx, pg.height - binh * by, binw, -binh); } } } else { drawCross(pg); } if (pdf) pg.dispose(); pg.endDraw(); }
PShape createTextGraphics(String s) { PGraphics buffer = createGraphics(width/2, height); buffer.beginDraw(); buffer.textSize(128); buffer.background(0x80800020); stroke(255); fill(255); buffer.text(s, width / 8, height / 2 + height / 4); buffer.endDraw(); PShape face = createShape(); face.beginShape(QUAD); face.noStroke(); face.textureMode(NORMAL); face.texture(buffer); face.vertex(-1, -1, 0, 0, 0); face.vertex(1, -1, 0, 1, 0); face.vertex(1, 1, 0, 1, 1); face.vertex(-1, 1, 0, 0, 1); face.endShape(); return face; }