In the code below, where I use the deadpixel library, my text is flickering, and I can't quite figure out why / how to stop it...
import deadpixel.keystone.*;
String[] texts =
{
"#peace, this is what I've wanted from SF --",
"market street is always so colorful, the",
"Opened Graffiti request via android at 990 Market St",
"the Opened Street or Sidewalk Cleaning request",
"via android at 1000 Market St",
"#sfc, join our lonely little squad tonight,",
"the operation nerds gathering, the new False Gods,",
"in for some #bigdatatalk, and to answer your email",
"#streetstyle #streetphotography #sf #walk #voyager:",
"I met this beautiful soul at the #BlueLamp a few months back --",
"just posted a photo,",
"so impressed,",
"I'm suffering through the widthdrawl..."};
String[] mentions =
{
"@melematique + @mistry_chintan",
"@JoCrra",
"@SF311 Reports",
"@SF311 Reports",
"@SF311 Reports",
"@totallyclubbin",
"@calitalieh + @catsynth",
"@agentv",
"@JoCrra",
"@Delany_Rene",
"@Delany_Rene",
"@WillKirkpatrick",
"@hchiu13",
};
DisplayBox dp1; //single
DisplayBox[] dps; //multiple
PFont font;
PFont fontS;
Keystone ks;
CornerPinSurface surface;
PGraphics offscreen;
float[] widthVariable;
float angle = 0;
float textFade = 0;
float tf = 0;
int counter = 0;
float rCounter = 0;
float tCounter = 0;
int switchVariable = 0;
void setup() {
font = loadFont("c.vlw");
fontS = loadFont("b.vlw");
//fullScreen(P3D, 1);
size(1325, 750, P3D);
ks = new Keystone(this);
surface = ks.createCornerPinSurface(1325, 750, 20);
offscreen = createGraphics(1325, 750, P3D);
//dp1 = new DisplayBox(0, texts[0], 0, height/2, 0);
dps = new DisplayBox[texts.length];
for (int i=0; i<texts.length; i++) {
dps[i] = new DisplayBox(i, texts[i], 10, 100+(i*50), 0);
}
widthVariable = new float[texts.length];
}
void draw() {
rCounter+=.05;
tCounter+=5;
//setting text widths;
for (int i=0; i<texts.length; i++) {
widthVariable[i]=offscreen.textWidth(texts[i])+20;
}
PVector surfaceMouse = surface.getTransformedMouse();
offscreen.beginDraw();
offscreen.background(0);
offscreen.textFont(font, 42);
offscreen.fill(255);
//(*.) try to figure out the flickering
//stroke, rect, text, rotate, translate;
//remember the transparency effects;
for (int i=0; i<texts.length; i++) {
dps[i].DRT(255, 5, 0, 255, 255, 255, 0, rCounter, 0, 0, 0, 0);
}
offscreen.endDraw();
background(0);
surface.render(offscreen);
//for text-fading;
textFade = sin(angle);
angle += 0.25;
tf = map(textFade, -1, 1, 255/2, 255);
}
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 DisplayBox {
//STRING DATA;
int sentenceW; //sentenceWidth;
String sentence; //the string;
//POSITION DATA;
float xPos; //x pos
float yPos; //y pos
float zPos; //z pos
//COLORS;
float sW; //stroke weight;
float rSC; //stroke color;
float rST; //stroke transparency;
float rFC; //fill color;
float rFT; //fill transparency;
float tF; //text fill;
float tT; //text transparency;
//TRANSLATIONS;
float transX; //move x
float transY; //move y
float transZ; //move z
//ROTATION DATA;
float ogX; //origin x
float ogY; //origin y
float ogZ; //origin z
DisplayBox(int sWI, String s, float xP, float yP, float zP) {
sentenceW = sWI;
sentence = s;
xPos = xP;
yPos = yP;
zPos = zP;
}
//colors, rotations, translations
void DRT(float rSC, float sW, float rFC, float rFT,
float tF, float tT, float rX, float rY,
float rZ, float transX, float transY, float transZ) {
ogX = xPos + widthVariable[sentenceW]/2;
ogY = yPos - 15;
ogZ = zPos;
offscreen.pushMatrix();
offscreen.translate(transX, transY, transZ);
offscreen.translate(ogX, ogY, ogZ);
offscreen.rotateX(rX);
offscreen.rotateY(rY);
offscreen.rotateZ(rZ);
offscreen.translate(-ogX, -ogY, -ogZ);
offscreen.stroke(rSC);
offscreen.strokeWeight(sW);
offscreen.fill(rFC, rFT);
offscreen.rect(xPos, yPos-42, widthVariable[sentenceW], 50);
offscreen.fill(tF, tT);
offscreen.text(sentence, xPos+5, yPos, zPos);
offscreen.popMatrix();
}
}