12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import java.util.*;
-
- //////// Config
-
- int autoplayMode = RANDOM; //NORMAL or RANDOM order
- int interactMode = NORMAL;
-
- float timerTime = 5000; //in milliseconds how long slide is shown
- float transitionTime = 1000; //how long it takes to fade the next slide in. must not be greater than "timerTime"
- float continueAutoplayTime = 60000; //how long until the app goes back to autoplay after a user interacted with it
-
- boolean displayText = true; //if the "date" should be written on screen
- boolean displayTimeline = true; //if the timeline should be drawn on screen
- boolean interactiveTimeline = true; //if the user can select a year via timeline
-
- //
-
- Timer timer;
- Timeline timeline;
- ArrayList<Notebook> notebooks = new ArrayList<Notebook>();
- PImage currentSlide, nextSlide;
- int currentNotebookNo, currentSlideNo;
- int startTransitionTime, startInteractionTime;
- boolean transition, interactive;
- float transitionProgress;
- final static int NORMAL = 0;
- final static int RANDOM = 1;
- String[] save;
-
- void setup() {
- //fullScreen(); //if using fullScreen, comment the next line
- size(960, 540);
- fill(255);
- save = loadStrings(dataPath("") + "/save.sav");
- currentNotebookNo = int(save[0]);
- currentSlideNo = int(save[1]);
-
- if (displayTimeline) {
- textSize(20);
- textAlign(CENTER);
- } else {
- textSize(20);
- }
- timer = new Timer(timerTime);
- timeline = new Timeline(50, height-30, width-100);
- createNotebooks();
- currentSlide = Slide(currentNotebookNo, currentSlideNo);
- }
-
- void draw() {
- if (!interactive) {
- timer.update();
- } else {
- if (millis() > startInteractionTime + continueAutoplayTime) {
- interactive = false;
- }
- }
-
- tint(255, 255);
- image(currentSlide, 0, 0, width, height);
-
- if (transition) {
- transitionProgress = map(millis(), startTransitionTime, startTransitionTime + transitionTime, 0, 255);
- tint(255, transitionProgress);
- image(nextSlide, 0, 0, width, height);
- if (millis() - startTransitionTime > transitionTime) {
-
- save[0] = str(currentNotebookNo);
- save[1] = str(currentSlideNo);
- saveStrings(dataPath("") + "/save.sav", save);
-
- currentSlide = nextSlide;
- transitionProgress = 0;
- transition = false;
- }
- }
-
-
- if (displayTimeline) {
- timeline.update();
- timeline.display();
- } else {
- if (displayText) text(notebooks.get(currentNotebookNo).dateText, 20, 40);
- }
- }
|