Using PApplet whilst extending classes like PGraphics

Heya Everyone!
I recently attempted to extend the PGraphics class specifically the PGraphicsJAVA2D class and referred to GotoLoop’s Solution
But don’t understand the code as well which leaves me with anxiety.

Then you should ask which exactly parts of the code you don’t understand. :wink:

the parts with the PApplet whilst defining the layer class.
I haven’t found anything useful regarding the PApplet class, as far as i know its the base class for any Processing sketch.
Also thanx for the reply, really appreciate it :slight_smile:

Processing.GitHub.io/processing-javadocs/everything/processing/core/PApplet.html

You mean from this very old sketch, right?

AFAIK, all PGraphics instances need to know which PApplet instance they should be bound to.

That’s why method Layer::initialize() calls PGraphics::setParent() within it:
Processing.GitHub.io/processing-javadocs/everything/processing/core/PGraphics.html#setParent-processing.core.PApplet-

public void initialize(int w, int h, PApplet p, String s) {
  setParent(p);
  setPrimary(false);
  setPath(s);
  setSize(w, h);
}
1 Like

Thank you so much for replying so actively : ) … I shall go through it and come back to clarify some extra things if necessary.
Again Thanx!