hamoid
March 16, 2020, 6:39pm
1
Hi there,
This is no longer behaving as it used to. If I’m not too sleepy, this program should draw a black screen, but I see it magenta. If inside draw()
I remove everything except image(...)
then it’s black.
PGraphics pg;
void setup() {
size(800, 800, P2D);
background(255, 0, 255);
pg = createGraphics(1000, 1000, P3D);
pg.beginDraw();
pg.background(0);
pg.endDraw();
}
void draw() {
pg.beginDraw();
//pg.stroke(random(10));
//pg.blendMode(ADD);
//pg.line(0, random(height), width, random(height));
pg.endDraw();
image(pg, 0, 0);
}
I also tried this but same magenta result:
PGraphics pg;
void setup() {
size(800, 800, P2D);
background(255, 0, 255);
}
void draw() {
if (pg == null) {
pg = createGraphics(1000, 1000, P3D);
pg.beginDraw();
pg.background(0);
pg.endDraw();
}
pg.beginDraw();
//pg.stroke(random(10));
//pg.blendMode(ADD);
//pg.line(0, random(height), width, random(height));
pg.endDraw();
image(pg, 0, 0);
}
Maybe someone could try this program to see if the issue is my OS? On Processing 3.5.4.
1 Like
hamoid
March 16, 2020, 6:52pm
2
Found an ugly workaround. I’m sad that old programs just stop working.
PGraphics pg;
void setup() {
size(800, 800, P2D);
background(255, 0, 255);
pg = createGraphics(1000, 1000, P3D);
}
void draw() {
pg.beginDraw();
if (frameCount == 2) {
pg.background(200, 100, 50);
}
pg.stroke(random(10));
pg.blendMode(ADD);
pg.line(0, random(height), width, random(height));
pg.blendMode(SUBTRACT);
pg.line(random(pg.width), 0, random(pg.width), pg.height);
pg.endDraw();
image(pg, 0, 0);
}
Screenshot with if(frameCount == 1)
(PGraphics is transparent):
Screenshot with if(frameCount == 2)
(PGraphics is opaque):
ps. I planned uploading one sketch per day from my collection, so here goes the first one:
noel
March 16, 2020, 7:27pm
3
Confirmed. Same thing here. The way until then will be
pg.fill(0); pg.rect(0,0,width,height);
1 Like
hamoid
March 16, 2020, 8:03pm
4
I tried the approach you suggest but doesn’t work for me. The background is still transparent.
noel
March 16, 2020, 8:54pm
5
hamoid:
doesn’t work for me
True, sorry. I forgot that I changed PGraphics from P3D to default at the same time…
noel
March 16, 2020, 9:20pm
6
Very nice!
Interesting that if you put the class in the first tab, you get a size error. Setup() has to be in the first tab.
@hamoid On 3.4 (MacOS) I can confirm that your top post sketches 1 and 2 both show magenta for a single frame, then show blank from then on. So something changed since 3.4.
Have you opened an issue?