We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I would like to have the geoMap.draw () into a separat PGraphics buffer. I tried several things but I couldn't push it into PGraphics.
Is this possible?
import org.gicentre.geomap.*;
import org.gicentre.utils.move.*;
GeoMap geoMap;
PGraphics pg;
void setup()
{
size(800, 400);
pg = createGraphics(800, 400);
geoMap = new GeoMap(this); // Create the geoMap object.
geoMap.readFile("world"); // Read shapefile.
}
void draw()
{
pg.beginDraw();
pg.background(0,0);
pg.geoMap.draw();
pg.endDraw();
noLoop();
}
Answers
Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
Notice:
geoMap = new GeoMap(this);
Here, the tokenthis
refers to current sketch. The drawing is done in the current sketch and checking the source code of the library, it does not provide any handle to draw on a separate pgraphics buffer. So what you are trying to do is not possible. If you describe what you want to do, you can get feedback or ideas how to implement your concept with the current lib design.Libraries follow certain design when deployed into processing. They are not mandated to provide handles to draw into an external buffer unfortunately.
Kf
Hi, thank you for explaining. I would like to have several layers for the map and borders as well an design overlay. The problem, if I zoom the main sketch, all PG Layers above the main sketch scales, and some shouldn't scale.
Which parts shouldn't scale? The design overlay?
You need to post an MCVE to demonstrate your approach and your issue.
Kf
Yes, just the overlay graphics shouldn't scale, so I tried to load this in a PGraphics above the Geomap layer, wich seem to be the sketch main layer.
Great. Did the PGraphics overlay work for you?
If not, have you tried looking at the gicentreUtils zoomExample? It zooms, but has a non-zooming text overlay.
@tom_tm -- Based on your earlier code, I feel like perhaps your question is the wrong one to solve your problem. You are trying to put the geoMap into its own layer -- but it is already drawn from its own layer. Instead, you need to isolate scaling of different drawn elements, and/or isolate your scaling.
You haven't given an example of what kinds of scaling or zooming you are trying to do -- is it built-in to geomap, or separate -- and you haven't explained why you can't just:
Anyway, assuming that in addition to the above approach you need an independent "HUD" text layer, here is a working example:
@jeremydouglass
Hi, thank you a lot for showing me the push/pop Matrix trick. Now I could isolate the transformation and have an overlay.
I will post later my sketch for other people looking into this.
Thank you again Tom
Relevant to your quest: https://processing.org/tutorials/transform2d/
Kf