fixed a bug where the effects woudlnt re-apply if a new image was loaded
This commit is contained in:
17
source.pde
17
source.pde
@@ -1,6 +1,6 @@
|
||||
Capture cam;
|
||||
Movie movie;
|
||||
boolean moviePlaying;
|
||||
boolean moviePlaying, imageChanged;
|
||||
PImage fallbackImage;
|
||||
|
||||
void movieEvent(Movie m) {
|
||||
@@ -29,13 +29,14 @@ boolean isImage(String path) {
|
||||
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.endDraw();
|
||||
}
|
||||
|
||||
|
||||
void setImage(PImage img) { //set image to source
|
||||
imageChanged = true;
|
||||
source = img.get();
|
||||
fallbackImage = source;
|
||||
nativeResoX = source.width;
|
||||
@@ -54,10 +55,10 @@ class SourceManager { //no constructor
|
||||
}
|
||||
|
||||
int toW, toH;
|
||||
if (source.width > source.height) {
|
||||
if (source.width > source.height) {
|
||||
toW = renderSize;
|
||||
toH = int(map(source.height, 0, source.width, 0, renderSize));
|
||||
} else {
|
||||
} else {
|
||||
toW = int(map(source.width, 0, source.height, 0, renderSize));
|
||||
toH = renderSize;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ class SourceManager { //no constructor
|
||||
}
|
||||
|
||||
|
||||
// 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) {
|
||||
File file = new File(dir);
|
||||
if (file.isDirectory()) {
|
||||
@@ -98,7 +99,7 @@ class SourceManager { //no constructor
|
||||
for (int i = 0; i < usableFiles.size(); i++) selection[i] = usableFiles.get(i);
|
||||
println("Got new selection from folder. " + selection.length + " usable files.");
|
||||
path = dir + "/" + selection[(int)random(selection.length)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isImage(path) || isVideo(path)) {
|
||||
|
||||
Reference in New Issue
Block a user