Play and zoom into movies to see details of videos that have a higher resolution than your screen
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.

classes.pde 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. class Viewport {
  2. PGraphics renderer;
  3. int movW;
  4. int movH;
  5. Viewport() {
  6. }
  7. void reload() {
  8. scaleFactor = 1;
  9. translateX = 0;
  10. translateY = 0;
  11. }
  12. void update() {
  13. renderer = createGraphics(width, height);
  14. if (mov.width > mov.height) {
  15. movW = width;
  16. movH = int(map(mov.height, 0, mov.width, 0, width));
  17. } else {
  18. movH = height;
  19. movW = int(map(mov.width, 0, mov.height, 0, height));
  20. }
  21. renderer.beginDraw();
  22. renderer.background(0);
  23. renderer.pushMatrix();
  24. renderer.translate(translateX, translateY);
  25. renderer.scale(scaleFactor);
  26. renderer.imageMode(CENTER);
  27. renderer.image(mov, width/2, height/2, movW, movH);
  28. renderer.popMatrix();
  29. renderer.endDraw();
  30. }
  31. void display() {
  32. image(renderer, 0, 0, width, height-timeline.h);
  33. }
  34. }
  35. class Timeline {
  36. int x, y, w, h;
  37. int playPos;
  38. boolean clicked;
  39. Timeline(int _x, int _y, int _w, int _h) {
  40. x = _x;
  41. y = _y;
  42. w = _w;
  43. h = _h;
  44. }
  45. void update() {
  46. y = height-20;
  47. w = width;
  48. playPos = int(map(mov.time(), 0, mov.duration(), 0, w));
  49. }
  50. void display() {
  51. noStroke();
  52. fill(127);
  53. rect(x, y, w, h);
  54. fill(255);
  55. rect(x, y, playPos, h);
  56. }
  57. boolean hover() {
  58. if (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h)
  59. return true;
  60. else
  61. return false;
  62. }
  63. void clicked() {
  64. clicked = true;
  65. jump();
  66. }
  67. void jump() {
  68. float f = map(mouseX-x, x, w, 0, 1);
  69. float t = mov.duration() * f;
  70. mov.jump(t);
  71. }
  72. }