compositor for 2d glitch effects
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mnglctrlr.pde 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. SecondApplet gui;
  30. void setup() {
  31. size(800, 600);
  32. w = width;
  33. h = height;
  34. frameRate(60);
  35. surface.setResizable(true);
  36. surface.setLocation(570, 240);
  37. noSmooth(); //saves resources but makes sum look shiddy
  38. imageMode(CENTER);
  39. drop = new SDrop(this);
  40. saveData = loadStrings(dataPath("saves.sav"));
  41. println("Loading Savefile...");
  42. for (int i = 0; i < saveData.length; i ++) {
  43. String[] temp;
  44. if (saveData[i].contains("uptime")) {
  45. temp = split(saveData[i], " = ");
  46. uptime = int(temp[1]);
  47. println("Uptime: " + uptime);
  48. }
  49. }
  50. fallbackImage = loadImage(dataPath("0.png"));
  51. bin = loadImage(dataPath("bin.png"));
  52. String[] args = {"SecondFrame"};
  53. gui = new SecondApplet();
  54. PApplet.runSketch(args, gui);
  55. renderer = createGraphics(width, height);
  56. renderer.noSmooth();
  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. viewport = renderer.get();
  69. int imgw, imgh;
  70. if (renderer.width < renderer.height) {
  71. imgh = (int)height;
  72. imgw = int((float(renderer.width)/float(renderer.height))*height);
  73. } else {
  74. imgw = (int)width;
  75. imgh = int((float(renderer.height)/float(renderer.width))*width);
  76. }
  77. image(viewport, width/2, height/2, imgw, imgh);
  78. if (videoRecord) {
  79. videoExport.saveFrame();
  80. fill(#ff0000);
  81. ellipse(width-100, height-100, 30, 30);
  82. }
  83. if (recording) {
  84. snapshot();
  85. fill(#ff0000);
  86. ellipse(width-100, height-100, 30, 30);
  87. }
  88. }
  89. void snapshot() {
  90. frameName = str(uptime);
  91. renderer.save(dataPath("")+"/snapshots/" + frameName + ".png");
  92. saveData[1] = "uptime = " + frameName;
  93. println("Rendered " + frameName + ".png at " + dataPath("")+"/snapshots/ with a resolution of " + renderer.width + " x " + renderer.height);
  94. saveStrings(dataPath("saves.sav"), saveData);
  95. }