Masked maps in Unfolding

As it seems the old thread https://discourse.processing.org/t/help-rounded-rectangle-unfolding-maps-masking-maps/11050 has been deleted, I wanted to add the example code somewhere for others to use. The following code needs Unfolding Maps 0.9.92 or up (which you can find in the Github repo, or send us an e-mail.)

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.mapdisplay.OpenGLMapDisplay;
import de.fhpotsdam.unfolding.mapdisplay.shaders.MaskedMapDisplayShader;
import de.fhpotsdam.unfolding.utils.MapUtils;
UnfoldingMap map;

MaskedMapDisplayShader mapDisplayShader;

void settings() {
  size(800, 800, P2D);
}

void setup() {
  map = new UnfoldingMap(this);
  MapUtils.createDefaultEventDispatcher(this, map);
  
  // Use any grayscale image as mask.
  PImage maskImage = loadImage("shader/mask-circular.png");
  mapDisplayShader = new MaskedMapDisplayShader(this, 400, 400, maskImage);
  ((OpenGLMapDisplay) map.mapDisplay).setMapDisplayShader(mapDisplayShader);
}

public void draw() {
  background(0);
  map.draw();
}
2 Likes

(Strange. Not sure why that thread was deleted – possibly the poster deleted their own account…)

Thank you so much for sharing this!

Could that version of Unfolding Maps be made available through PDE Contributions Manager as well?