//globals | //globals | ||||
uptime = 116747025 | |||||
uptime = 116755249 |
background(color(0)); | background(color(0)); | ||||
viewport = renderer.get(); | viewport = renderer.get(); | ||||
int imgw, imgh; | int imgw, imgh; | ||||
if (renderer.width < renderer.height) { | if (renderer.width < renderer.height) { | ||||
imgh = (int)height; | imgh = (int)height; | ||||
} | } | ||||
} | } | ||||
void snapshot() { | void snapshot() { | ||||
frameName = str(uptime); | frameName = str(uptime); | ||||
renderer.save(dataPath("")+"/snapshots/" + frameName + ".png"); | renderer.save(dataPath("")+"/snapshots/" + frameName + ".png"); |
println(e); | println(e); | ||||
} | } | ||||
//this is only for checking if a param has changed. paramValues could also be used for a save/load function | |||||
if (paramValues.size() != params.size()) { | if (paramValues.size() != params.size()) { | ||||
for (int i = 0; i < params.size(); i++) { | for (int i = 0; i < params.size(); i++) { | ||||
paramValues.add(0.0); | paramValues.add(0.0); | ||||
} | } | ||||
} | } | ||||
paramChanged = false; | paramChanged = false; | ||||
for (int i = 0; i < params.size(); i++) { | for (int i = 0; i < params.size(); i++) { | ||||
if (paramValues.get(i) != params.get(i).value) { | if (paramValues.get(i) != params.get(i).value) { | ||||
paramChanged = true; | paramChanged = true; | ||||
} | } | ||||
} | } | ||||
if(pos != previousPos){ | |||||
if (pos != previousPos) { | |||||
paramChanged = true; | paramChanged = true; | ||||
} | } | ||||
previousPos = pos; | previousPos = pos; | ||||
if(previousActive != gui.bricks.get(pos).active){ | |||||
if (previousActive != gui.bricks.get(pos).active) { | |||||
paramChanged = true; | paramChanged = true; | ||||
} | } | ||||
previousActive = gui.bricks.get(pos).active; | previousActive = gui.bricks.get(pos).active; | ||||
if (!paramChanged) { | if (!paramChanged) { | ||||
if (imageChanged) paramChanged = true; | |||||
for (int i = this.pos; i >= 0; i--) { | for (int i = this.pos; i >= 0; i--) { | ||||
if (gui.shaderList.get(i).paramChanged) paramChanged = true; | if (gui.shaderList.get(i).paramChanged) paramChanged = true; | ||||
} | } | ||||
gui.bricks.get(pos).params.remove(paramNo); | gui.bricks.get(pos).params.remove(paramNo); | ||||
gui.bricks.get(pos).params.add(paramNo, newParam); | gui.bricks.get(pos).params.add(paramNo, newParam); | ||||
gui.bricks.get(pos).exchangeSlider(paramNo, newParam); | gui.bricks.get(pos).exchangeSlider(paramNo, newParam); | ||||
paramChanged = true; | |||||
} | } | ||||
void shade() { | void shade() { | ||||
result.beginDraw(); | result.beginDraw(); | ||||
result.image(renderer, 0, 0); | result.image(renderer, 0, 0); | ||||
result.endDraw(); | result.endDraw(); | ||||
if (pos == gui.bricks.size()-1) { | |||||
//println("Finished rendering"); | |||||
if (imageChanged) { //kind of hacky but it does synchronize the threads. | |||||
stepOne++; | |||||
if (stepOne == 2) { | |||||
stepOne = 0; | |||||
imageChanged = false; | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
int stepOne = 0; |
Capture cam; | Capture cam; | ||||
Movie movie; | Movie movie; | ||||
boolean moviePlaying; | |||||
boolean moviePlaying, imageChanged; | |||||
PImage fallbackImage; | PImage fallbackImage; | ||||
void movieEvent(Movie m) { | void movieEvent(Movie m) { | ||||
class SourceManager { //no constructor | class SourceManager { //no constructor | ||||
void setSource() { //set source to renderer | |||||
renderer.beginDraw(); | |||||
void setSource() { //set source to renderer | |||||
renderer.beginDraw(); | |||||
renderer.image(source, 0, 0, renderer.width, renderer.height); | renderer.image(source, 0, 0, renderer.width, renderer.height); | ||||
renderer.endDraw(); | renderer.endDraw(); | ||||
} | } | ||||
void setImage(PImage img) { //set image to source | void setImage(PImage img) { //set image to source | ||||
imageChanged = true; | |||||
source = img.get(); | source = img.get(); | ||||
fallbackImage = source; | fallbackImage = source; | ||||
nativeResoX = source.width; | nativeResoX = source.width; | ||||
} | } | ||||
int toW, toH; | int toW, toH; | ||||
if (source.width > source.height) { | |||||
if (source.width > source.height) { | |||||
toW = renderSize; | toW = renderSize; | ||||
toH = int(map(source.height, 0, source.width, 0, renderSize)); | toH = int(map(source.height, 0, source.width, 0, renderSize)); | ||||
} else { | |||||
} else { | |||||
toW = int(map(source.width, 0, source.height, 0, renderSize)); | toW = int(map(source.width, 0, source.height, 0, renderSize)); | ||||
toH = renderSize; | toH = renderSize; | ||||
} | } | ||||
} | } | ||||
// This function returns all the files in a directory as an array of Strings | |||||
// This function returns all the files in a directory as an array of Strings | |||||
String[] listFileNames(String dir) { | String[] listFileNames(String dir) { | ||||
File file = new File(dir); | File file = new File(dir); | ||||
if (file.isDirectory()) { | if (file.isDirectory()) { | ||||
for (int i = 0; i < usableFiles.size(); i++) selection[i] = usableFiles.get(i); | for (int i = 0; i < usableFiles.size(); i++) selection[i] = usableFiles.get(i); | ||||
println("Got new selection from folder. " + selection.length + " usable files."); | println("Got new selection from folder. " + selection.length + " usable files."); | ||||
path = dir + "/" + selection[(int)random(selection.length)]; | path = dir + "/" + selection[(int)random(selection.length)]; | ||||
} | |||||
} | |||||
if (isImage(path) || isVideo(path)) { | if (isImage(path) || isVideo(path)) { |