117 lines
2.9 KiB
Plaintext
117 lines
2.9 KiB
Plaintext
import drop.*;
|
|
import controlP5.*;
|
|
|
|
import java.util.*;
|
|
import processing.net.*;
|
|
import java.awt.event.KeyEvent;
|
|
import java.awt.event.KeyListener;
|
|
import processing.video.*;
|
|
import com.hamoid.*;
|
|
|
|
VideoExport videoExport;
|
|
|
|
int maxFx = 15; //possible amount of effect layers
|
|
SDrop drop;
|
|
PImage source;
|
|
PGraphics renderer;
|
|
PImage viewport;
|
|
SourceManager sourceManager;
|
|
String frameName; //to save frame as image
|
|
int uptime; //logs how many frames this software has rendered before (inaccurate, it's actually way, way more)
|
|
boolean recording; //save every frame?
|
|
int renderSize = 500; //px
|
|
String[] saveData;
|
|
int w, h;
|
|
|
|
boolean videoRecord;
|
|
|
|
String[] params;
|
|
|
|
PImage droppedImage;
|
|
void dropEvent(DropEvent theDropEvent) {
|
|
|
|
sourceManager.importURI(theDropEvent.filePath());
|
|
}
|
|
|
|
void settings() {
|
|
size(800, 600);
|
|
}
|
|
|
|
SecondApplet gui;
|
|
|
|
void setup() {
|
|
w = width;
|
|
h = height;
|
|
frameRate(60);
|
|
surface.setResizable(true);
|
|
surface.setLocation(570, 240);
|
|
noSmooth(); //saves resources but makes sum look shiddy
|
|
drop = new SDrop(this);
|
|
saveData = loadStrings(dataPath("saves.sav"));
|
|
println("Loading Savefile...");
|
|
for (int i = 0; i < saveData.length; i ++) {
|
|
String[] temp;
|
|
if (saveData[i].contains("uptime")) {
|
|
temp = split(saveData[i], " = ");
|
|
uptime = int(temp[1]);
|
|
println("Uptime: " + uptime);
|
|
}
|
|
}
|
|
fallbackImage = loadImage(dataPath("0.png"));
|
|
bin = loadImage(dataPath("bin.png"));
|
|
|
|
|
|
String[] args = {"SecondFrame"};
|
|
gui = new SecondApplet();
|
|
PApplet.runSketch(args, gui);
|
|
|
|
renderer = createGraphics(width, height);
|
|
viewport = createImage(renderer.width, renderer.height, ARGB);
|
|
sourceManager = new SourceManager();
|
|
//sourceManager.importURI("/home/giers/.local/bin/fast-style-transfer/data/train2014");
|
|
}
|
|
|
|
void draw() {
|
|
uptime+=1;
|
|
background(255);
|
|
|
|
sourceManager.update(); //will write some image to the renderer
|
|
sourceManager.setSource();
|
|
gui.shaderManager.applyShader(); //boolean animate (iterative calcs), boolean apply (draw)
|
|
|
|
background(color(0));
|
|
imageMode(CENTER);
|
|
viewport = renderer.get();
|
|
if (renderer.width < renderer.height) {
|
|
viewport.resize(0, height);
|
|
if (viewport.width > width) viewport.resize(width, 0);
|
|
} else {
|
|
viewport.resize(width, 0);
|
|
if (viewport.height > height) viewport.resize(0, height);
|
|
}
|
|
|
|
//sourceManager.setSource();
|
|
image(viewport, width/2, height/2);
|
|
|
|
if (videoRecord) {
|
|
videoExport.saveFrame();
|
|
fill(#ff0000);
|
|
ellipse(width-100, height-100, 30, 30);
|
|
}
|
|
|
|
|
|
if (recording) {
|
|
snapshot();
|
|
fill(#ff0000);
|
|
ellipse(width-100, height-100, 30, 30);
|
|
}
|
|
}
|
|
|
|
void snapshot() {
|
|
frameName = str(uptime);
|
|
renderer.save(dataPath("")+"/snapshots/" + frameName + ".png");
|
|
saveData[1] = "uptime = " + frameName;
|
|
println("Rendered " + frameName + ".png at " + dataPath("")+"/snapshots/ with a resolution of " + renderer.width + " x " + renderer.height);
|
|
saveStrings(dataPath("saves.sav"), saveData);
|
|
}
|