We are about to switch to a new forum software. Until then we have removed the registration on this forum.
function setup() {
var g = createGraphics(200, 200);
var img = createImage(200, 200, RGB);
g.loadPixels();
println(g.pixels.length);
img.loadPixels();
println(img.pixels.length);
}
print out:
0
160000
Answers
Hmm it should have... Perhaps it is only created after beginDraw()/endDraw() ?
PGraphics
extends
PImage.Therefore PGraphics got everything a PImage does.
https://Processing.org/reference/extends.html
Oooopps, my bad also. I missed the
var
and the tag. The code you posted just works fine in java mode...Can we make a request for this feature in P5?
@GotoLoop https://github.com/processing/p5.js/issues/995 I guess you were heard. <:-P I was trying to fix it.
I was just wondering about that... I was hoping this would work:
But I don't think it does. (PS how do I do a fancy code block?)
I was trying to code an example to test p5.Image & p5.Graphics together and stumbled in a puzzling nasty halting bug after issuing updatePixels(), which I've got no idea why! ~X(
Found the halting bug. 2nd
for
loop needed an ending semi-colon;
in order not to pick up
img.updatePixels()
! X_XBut it turns out that p5.Renderer objects don't have property pixels[] at all!
But surprisingly, main p5.Renderer canvas is the exception and it got 1!!! 8-}