Text in combination with PGraphics
in
Programming Questions
•
3 years ago
Hi,
I'm having some big problems tryoung to doublebuffer my text. Text behaves totally unnormally in comparison to normal elements or text used directly.
I wrote a quick program to show you what I mean.
Why it's so important to buffer the text before drawign it, is that in my original program I need to draw every single character on by one as I am doing a wordwrap combined with styling code in the string.
Drawing it out directly is very slow, using buffering is very quick.... but ugly...
Who can help me??
Thanks!
I'm having some big problems tryoung to doublebuffer my text. Text behaves totally unnormally in comparison to normal elements or text used directly.
I wrote a quick program to show you what I mean.
- PFont myFont;
PGraphics pg;
void setup() {
size(400,400);
myFont = loadFont("Verdana-24.vlw");
textFont(myFont);
textMode(SCREEN);
pg = createGraphics(180, 380, P3D);
noLoop();
}
void draw() {
background(128);
// How it should look
fill(0);
rect(10,10,180,380);
fill(255);
smooth();
text("This is a Test!", 20, 200);
// Want it to look like above, but doesn't
pg.beginDraw();
pg.fill(0);
pg.rect(10,10,180,380);
pg.fill(255);
pg.smooth();
pg.text("This is a Test!", 20, 200);
pg.endDraw();
image(pg, 210, 10);
}
Why it's so important to buffer the text before drawign it, is that in my original program I need to draw every single character on by one as I am doing a wordwrap combined with styling code in the string.
Drawing it out directly is very slow, using buffering is very quick.... but ugly...
Who can help me??
Thanks!
2