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

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