Last active
September 10, 2018 21:26
-
-
Save REAS/491b9f6c4201d8dc5ba715d70d675d42 to your computer and use it in GitHub Desktop.
Converts a JSON file with values from -1 to 1 into a line of gray rectangles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float[] latentspace; | |
String s = "RandGen_20180904-201026_00036"; // JSON file name | |
void setup() { | |
size(1000, 100); | |
loadData(); | |
int w = 10; | |
int h = 100; | |
for (int i = 0; i < latentspace.length; i++) { | |
float g = map(latentspace[i], -1, 1, 0, 255); | |
fill(g); | |
noStroke(); | |
rect(i*w, 0, w, h); | |
} | |
saveFrame(s + ".png"); | |
println("finished..."); | |
exit(); | |
} | |
void loadData() { | |
JSONArray data = loadJSONArray(s + ".json"); | |
println(data.size()); | |
latentspace = new float[data.size()]; | |
for (int i = 0; i < latentspace.length; i++) { | |
latentspace[i] = data.getFloat(i); | |
println(latentspace[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment