compositor for 2d shader
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.

9 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. class FX {
  2. //img in and out
  3. Shader shader;
  4. String[] params; // IS THIS NECESSARY? I DOUBT IT
  5. FX(Shader shader_) {
  6. shader = shader_;
  7. }
  8. }
  9. FXManager fxManager = new FXManager();
  10. class FXManager {
  11. ArrayList<FX> fxList = new ArrayList<FX>();
  12. void addFx(Shader shader) {
  13. this.fxList.add(new FX(shader));
  14. println("Added " + shader + " to fxList at spot. List length: " + this.fxList.size());
  15. }
  16. void addFx(Shader shader, int pos) {
  17. fxList.add(new FX(shader));
  18. swapFx(this.fxList.size(), pos);
  19. println("Added " + shader + " to fxList at spot. List length: " + this.fxList.size());
  20. }
  21. void swapFx(int pos1, int pos2) {
  22. if (pos1 >= 0 && pos2 < this.fxList.size()) Collections.swap(fxList, pos1, pos2);
  23. }
  24. void removeFx(int pos) {
  25. if (pos >= 0 && this.fxList.size() > pos) this.fxList.remove(pos);
  26. }
  27. void run(boolean animate, boolean apply) {
  28. for (int i = 0; i < fxManager.fxList.size(); i++) {
  29. if (animate) {
  30. for (int j = 0; j < this.fxList.get(i).shader.params.size(); j++) {
  31. if (this.fxList.get(i).shader.params.get(j).animating) {
  32. this.fxList.get(i).shader.params.get(j).animate();
  33. }
  34. }
  35. }
  36. if (apply) this.fxList.get(i).shader.apply();
  37. if (i > maxFx) break;
  38. }
  39. }
  40. }