Created
September 11, 2018 20:47
-
-
Save REAS/4aa15dd101d5b3d781a99f105880f6ab to your computer and use it in GitHub Desktop.
Converts a JSON file with values from -1 to 1 into a line of rectangles moving through hues from orange to blue
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); | |
colorMode(HSB, 360, 100, 100); | |
loadData(); | |
int w = 10; | |
int h = 100; | |
for (int i = 0; i < latentspace.length; i++) { | |
int orange = 25; | |
int blue = 210; | |
float c = map(latentspace[i], -1, 1, orange, blue); | |
fill(c, 70, 80); | |
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