There seems to be some kind of conflict while combining the PGraphics and a PShape. The normal shape functions work fine but as soon as you try to use a PShape, the PGraphics.background functions covers the drawing, even when placed before the shape is drawn. I think it’s a bug.
This is my same sketch from my last post, if you uncomment ‘pg.background’ it no longer works.
import deadpixel.keystone.*;
Keystone ks;
CornerPinSurface surface;
PGraphics pg;
//int pgWidth = 1280;
//int pgHeight = 1024;
int pgWidth = 320;
int pgHeight = 240;
Five_Circles fiveCircles;
void setup() {
//fullScreen(P3D, 2);
size(320, 240, P3D);
pg = createGraphics(pgWidth, pgHeight, P3D);
fiveCircles = new Five_Circles(pg, pgWidth, pgHeight);
ks = new Keystone(this);
surface = ks.createCornerPinSurface(pgWidth, pgHeight, 20);
}
void draw() {
background(0);
pg.beginDraw();
pg.background(0);
fiveCircles.render();
pg.endDraw();
//fiveCircles.display();
surface.render(pg);
}
void keyPressed() {
switch(key) {
case 'c':
// enter/leave calibration mode, where surfaces can be warped
// and moved
ks.toggleCalibration();
break;
case 'l':
// loads the saved layout
ks.load();
break;
case 's':
// saves the layout
ks.save();
break;
}
}
class Five_Circles {
PGraphics masterContext;
int masterContextWidth;
int masterContextHeight;
PShape ellipse;
float scale;
Five_Circles(PGraphics masterContextTemp, int masterContextWidthTemp, int masterContextHeightTemp) {
masterContext = masterContextTemp;
masterContextWidth = masterContextWidthTemp;
masterContextHeight = masterContextHeightTemp;
scale = 1;
}
void render() {
float ellipseWidth = 1;
float ellipseHeight = 1;
float xOffset = 0.5;
float yOffset = 0.5;
float redStroke = 255;
float greenStroke = 0;
float blueStroke = 0;
float alphaStroke = 255;
float redFill = 0;
float greenFill = 0;
float blueFill = 0;
float alphaFill = 0;
ellipse = createShape(ELLIPSE, 0, 0, 100, 100);
ellipse.setStroke(color(redStroke, greenStroke,
blueStroke, alphaStroke));
ellipse.setFill(color(redFill, greenFill, blueFill, alphaFill));
ellipse.scale(scale);
masterContext.shape(ellipse, (pgWidth/2) + (xOffset), (pgHeight/2) + (yOffset));
masterContext.shape(ellipse, 0 + (xOffset), 0 + (yOffset));
masterContext.shape(ellipse, pgWidth + (xOffset), 0 + (yOffset));
masterContext.shape(ellipse, 0 + (xOffset), pgHeight + (yOffset));
masterContext.shape(ellipse, pgWidth + (xOffset), pgHeight + (yOffset));
}
void display() {
image(masterContext, 0, 0, width, height);
}
}