Skip to content

Instantly share code, notes, and snippets.

@dimkir
Created November 12, 2013 14:17
Show Gist options
  • Save dimkir/7431523 to your computer and use it in GitHub Desktop.
Save dimkir/7431523 to your computer and use it in GitHub Desktop.
Processing sketch : worldMapProject
/**
* This is automatically generated code.
* It is re-inserted into sketch every time code is inserted into PDE.
* Purpose of this code is to implement functionality of saving screenshot
* of running sketch on keyboard key release.
*/
@Override
void keyReleased(KeyEvent evt){
println("*******************keyEvent: " + evt.getAction() );
if ( evt.getAction() == KeyEvent.RELEASE ){
// release is triggered only once
// PRESS ( despite it's name is triggered
// on first key press and then repeated
// every half a second (despite it's the
// behaviour more suitable for TYPE event.
saveFrame(getFrameName());
}
super.keyPressed(evt);
}
/**
* Generates frame names for the
* screenshots.
* We will probably use System.time because
* in typical usage scenario, for cretive coder would look
* like this:
*
*/
String getFrameName(){
return "frame_" + System.currentTimeMillis() + ".png";
}
//#GIST:7431523
PShape worldMap;
void setup(){
size(displayWidth, displayHeight);
worldMap = loadShape("world_map.svg");
printChildren(worldMap);
}
void printChildren(PShape shp){
if ( shp.getChildCount() == 0 ){
return;
}
println("Children: " + shp.getChildCount());
for( int i = 0 ; i < shp.getChildCount() ; i++){
printChildren(shp.getChild(i));
}
}
void draw(){
shape(worldMap,0,0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment