Skip to content

Commit

Permalink
Adding class examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
blprnt committed Sep 29, 2014
1 parent 7e98614 commit 238fdda
Show file tree
Hide file tree
Showing 3 changed files with 21,600 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 2_Text_and_Archive/Code/ImageFromWord/ImageFromWord.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
PImage img;

void setup() {
size(1280, 720);
img = getImage("frog");

}

void draw() {
if (img.width > 1) image(img,0,0);
}

PImage getImage(String topic) {
PImage img = null;
try {
String url = "https://www.googleapis.com/freebase/v1/topic/en/" + topic + "?filter=/common/topic/image&limit=1";
JSONObject json = loadJSONObject(url);
String id = json.getJSONObject("property").getJSONObject("/common/topic/image").getJSONArray("values").getJSONObject(0).getString("id");
String imgUrl = "https://usercontent.googleapis.com/freebase/v1/image" + id + "?maxwidth=200&junk=.jpg";
img = requestImage(imgUrl);
}
catch (Exception e) {
println("Image not found?");
}
return(img);
}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 238fdda

Please sign in to comment.