123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //182l 31h 25t
-
- 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 spawnPlaying = true;
-
- 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);
- }
|