compositor for 2d glitch effects
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mnglctrlr.pde 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import drop.*;
  2. import controlP5.*;
  3. import java.util.*;
  4. import processing.net.*;
  5. import java.awt.event.KeyEvent;
  6. import java.awt.event.KeyListener;
  7. import processing.video.*;
  8. import com.hamoid.*;
  9. VideoExport videoExport;
  10. int maxFx = 15; //possible amount of effect layers
  11. SDrop drop;
  12. PImage source;
  13. PGraphics renderer;
  14. PImage viewport;
  15. SourceManager sourceManager;
  16. String frameName; //to save frame as image
  17. int uptime; //logs how many frames this software has rendered before (inaccurate, it's actually way, way more)
  18. boolean recording; //save every frame?
  19. int renderSize = 500; //px
  20. String[] saveData;
  21. int w, h;
  22. boolean spawnPlaying = true;
  23. boolean videoRecord;
  24. String[] params;
  25. PImage droppedImage;
  26. void dropEvent(DropEvent theDropEvent) {
  27. sourceManager.importURI(theDropEvent.filePath());
  28. }
  29. void settings() {
  30. size(800, 600);
  31. }
  32. SecondApplet gui;
  33. void setup() {
  34. w = width;
  35. h = height;
  36. frameRate(60);
  37. surface.setResizable(true);
  38. surface.setLocation(570, 240);
  39. noSmooth(); //saves resources but makes sum look shiddy
  40. drop = new SDrop(this);
  41. saveData = loadStrings(dataPath("saves.sav"));
  42. println("Loading Savefile...");
  43. for (int i = 0; i < saveData.length; i ++) {
  44. String[] temp;
  45. if (saveData[i].contains("uptime")) {
  46. temp = split(saveData[i], " = ");
  47. uptime = int(temp[1]);
  48. println("Uptime: " + uptime);
  49. }
  50. }
  51. fallbackImage = loadImage(dataPath("0.png"));
  52. bin = loadImage(dataPath("bin.png"));
  53. String[] args = {"SecondFrame"};
  54. gui = new SecondApplet();
  55. PApplet.runSketch(args, gui);
  56. renderer = createGraphics(width, height);
  57. viewport = createImage(renderer.width, renderer.height, ARGB);
  58. sourceManager = new SourceManager();
  59. //sourceManager.importURI("/home/giers/.local/bin/fast-style-transfer/data/train2014");
  60. }
  61. void draw() {
  62. uptime+=1;
  63. background(255);
  64. sourceManager.update(); //will write some image to the renderer
  65. sourceManager.setSource();
  66. gui.shaderManager.applyShader(); //boolean animate (iterative calcs), boolean apply (draw)
  67. background(color(0));
  68. imageMode(CENTER);
  69. viewport = renderer.get();
  70. if (renderer.width < renderer.height) {
  71. viewport.resize(0, height);
  72. if (viewport.width > width) viewport.resize(width, 0);
  73. } else {
  74. viewport.resize(width, 0);
  75. if (viewport.height > height) viewport.resize(0, height);
  76. }
  77. //sourceManager.setSource();
  78. image(viewport, width/2, height/2);
  79. if (videoRecord) {
  80. videoExport.saveFrame();
  81. fill(#ff0000);
  82. ellipse(width-100, height-100, 30, 30);
  83. }
  84. if (recording) {
  85. snapshot();
  86. fill(#ff0000);
  87. ellipse(width-100, height-100, 30, 30);
  88. }
  89. }
  90. void snapshot() {
  91. frameName = str(uptime);
  92. renderer.save(dataPath("")+"/snapshots/" + frameName + ".png");
  93. saveData[1] = "uptime = " + frameName;
  94. println("Rendered " + frameName + ".png at " + dataPath("")+"/snapshots/ with a resolution of " + renderer.width + " x " + renderer.height);
  95. saveStrings(dataPath("saves.sav"), saveData);
  96. }