Flashing polygon in Folding Map

edited October 2014 in Library Questions

I have the following code, which is a region of Cyprus and a polygon inside the area. I try to add the second part of the code that I have below so the polygon flashing according to the value you have in the variable delay. Any idea how to combine the second code to first or the opposite?

MAP CODE

import de.fhpotsdam.unfolding.mapdisplay.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.marker.*;
import de.fhpotsdam.unfolding.tiles.*;
import de.fhpotsdam.unfolding.interactions.*;
import de.fhpotsdam.unfolding.ui.*;
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.core.*;
import de.fhpotsdam.unfolding.mapdisplay.shaders.*;
import de.fhpotsdam.unfolding.data.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.texture.*;
import de.fhpotsdam.unfolding.events.*;
import de.fhpotsdam.utils.*;
import de.fhpotsdam.unfolding.providers.*;
import java.util.List;
UnfoldingMap map;

void setup() {
  size(800, 600);

int i=0,k=15;

  map = new UnfoldingMap(this, new Microsoft.AerialProvider());
  Location cyprusLocation = new Location(35f, 33f);
  map.zoomAndPanTo(cyprusLocation, 11);
  float maxPanningDistance = 30; // in km
  map.setPanningRestriction(cyprusLocation, maxPanningDistance);
  //map = new UnfoldingMap(this);
  MapUtils.createDefaultEventDispatcher(this, map);

  List<Feature> countries = GeoJSONReader.loadData(this, "Dasos.geo.json");
  List<Marker> countryMarkers = MapUtils.createSimpleMarkers(countries);
  map.addMarkers(countryMarkers);

  for (Marker marker : countryMarkers) {
 marker.setColor(color(255, 0, 0));
}
}
void draw() {
  map.draw();
}
void keyPressed() {
  if (key == ' ') {
    map.getDefaultMarkerManager().toggleDrawing();
  }
}

FLASHING PROGRAMM

float delay = 12; // 1 frame
void setup() {
  size(200, 200);
}
void draw() { 
  background(96); //Background colour 96 is gray
  fill(255);        // Start with white
  if(frameCount%(2*delay)<delay) fill(255, 0, 0);/* frameCount() --> The system /*variable frameRate contains the approximate frame rate of a running sketch. % /*--> Calculates the remainder when one number is divided by another.*/
  rect(50, 50, 100, 100);// Draws a rectangle to the screen
}
Tagged:

Answers

  • Simply use the marker.setColor(..) instead of the fill(..) inside of your frameCount condition.

Sign In or Register to comment.