Setting width and height in a PGraphics derivative after it has been initialized
in
Library and Tool Development
•
2 years ago
Hi,
I am working on a PGraphics derivative for sending HPGL-commands to an old plotter on the serial port, and have some problems regarding width and height.
The width and height of the paper is determined by the plotter, depending on the size of the paper that is put into it, so it is hard/meaningless to know what that should be when you call size() e.g. in setup().
The thing is, as it is now, I can't find the size of the paper before I get to allocate(), and would then like to set the new values for width/height in the pgraphics instance, but what seems to happen is that those values keep getting reset before each frame.
What is the proper way to do this?
Kinda what happens now is something like
size(0, 0, "PGraphicsHPGL") is called from the sketch.. and in my PGraphicsHPGL:
Constructor
Allocate
CheckPaperSize
Set width and height
but back in draw, when I try to check width, it is back at 0
I am working on a PGraphics derivative for sending HPGL-commands to an old plotter on the serial port, and have some problems regarding width and height.
The width and height of the paper is determined by the plotter, depending on the size of the paper that is put into it, so it is hard/meaningless to know what that should be when you call size() e.g. in setup().
The thing is, as it is now, I can't find the size of the paper before I get to allocate(), and would then like to set the new values for width/height in the pgraphics instance, but what seems to happen is that those values keep getting reset before each frame.
What is the proper way to do this?
Kinda what happens now is something like
size(0, 0, "PGraphicsHPGL") is called from the sketch.. and in my PGraphicsHPGL:
Constructor
Allocate
CheckPaperSize
Set width and height
but back in draw, when I try to check width, it is back at 0
1