We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'd like to build a class that contains a PGraphics object and write to it from outside the class (in setup()
, draw()
, etc). I can do this now, but it's clunky:
thing.pg.beginDraw();
thing.pg.rect(0,0, 10,10);
thing.pg.endDraw();
I'd like to be able to do something more like this:
thing.beginDraw();
thing.rect(0,0, 10,10);
thing.endDraw();
I know I can create new functions for rect()
, etc inside the class, but that's ugly. I found this post, which offers some hope, but not sure how to make it work in my case.
Answers
You can make your class extend PGraphics, provided you can make it somehow fit into your class scheme.
http://forum.Processing.org/two/discussions/tagged/pgraphicsjava2d
Thanks both of you – I did see the "layer" post that GoToLoop posted. But the thread is very confusing and I don't have much experience with extending classes. Could you show me a very simple class that does this?
(For example, the exampled linked to above also gets the parent applet and does some other stuff – is that necessary too?)
https://forum.Processing.org/two/discussion/6884/question-about-pgraphics#Item_3