Kaynağa Gözat

initial commit

master
Victor Giers 1 yıl önce
işleme
04d519b2a8
4 değiştirilmiş dosya ile 196 ekleme ve 0 silme
  1. 76
    0
      Notebook.pde
  2. 39
    0
      Slide.pde
  3. 16
    0
      Timer.pde
  4. 65
    0
      notizheftanzeiger.pde

+ 76
- 0
Notebook.pde Dosyayı Görüntüle

@@ -0,0 +1,76 @@
class Notebook {
String notebookpath;
String[] imagepaths;
String dateText;
int year;
int id;
Notebook(int id_, String notebookpath_, String[] imagepaths_) {
id = id_;
notebookpath = dataPath("") + "/" + notebookpath_;
imagepaths = Arrays.copyOfRange(imagepaths_, 1, imagepaths_.length-1);
String[] separated = notebookpath_.split("-");
dateText = (getMonth(int(separated[1])) + " " + separated[0]);
year = int(separated[0]);
}
}

String getMonth(int id) {
switch(id) {
case(1):
return("January");
case(2):
return("February");
case(3):
return("March");
case(4):
return("April");
case(5):
return("May");
case(6):
return("June");
case(7):
return("July");
case(8):
return("August");
case(9):
return("September");
case(10):
return("October");
case(11):
return("November");
case(12):
return("December");
default:
return " ";
}
}


ArrayList<Notebook> notebooks = new ArrayList<Notebook>();

void createNotebooks() {
File datafolder = new File(dataPath(""));
String[] notebooknames = datafolder.list();
notebooknames = sort(notebooknames);
int notebookID = 0;
for (int i = 0; i < notebooknames.length; i++) {
File notebookfolder = new File(dataPath("") + "/" + notebooknames[i]);
if (notebookfolder.list() != null) {
String[] imagenames = notebookfolder.list();
List<String> strings = Arrays.asList(imagenames);
Collections.sort(strings, new Comparator<String>() {
public int compare(String o1, String o2) {
return extractInt(o1) - extractInt(o2);
}
int extractInt(String s) {
String num = s.replaceAll("\\D", "");
return num.isEmpty() ? 0 : Integer.parseInt(num);
}
}
);
imagenames = strings.toArray(imagenames);
notebooks.add(new Notebook(notebookID, notebooknames[i], imagenames));
notebookID ++;
}
}
}

+ 39
- 0
Slide.pde Dosyayı Görüntüle

@@ -0,0 +1,39 @@
PImage Slide(int notebookID, int pageNumber) {
PImage leftPage, rightPage;
PGraphics result;
String path = notebooks.get(notebookID).notebookpath + "/";
leftPage = loadImage(path + notebooks.get(notebookID).imagepaths[pageNumber]);
rightPage = loadImage(path + notebooks.get(notebookID).imagepaths[pageNumber+1]);
result = createGraphics(width, height);
result.beginDraw();
result.image(leftPage, 0, 0, result.width/2, result.height);
result.image(rightPage, result.width/2, 0, result.width/2, result.height);
result.endDraw();
PImage res = createImage(width, height, ARGB);
res = result.get();
return res;
}

boolean transition;

void nextSlide() {
transition = true;
startTransitionTime = millis();
if (mode == NORMAL) {
currentSlideNo+=2;
if (currentSlideNo > notebooks.get(currentNotebookNo).imagepaths.length-1) {
currentSlideNo = 0;
currentNotebookNo++;
}
} else if (mode == RANDOM) {
currentNotebookNo = (int)random(notebooks.size());
currentSlideNo = (int)random(notebooks.get(currentNotebookNo).imagepaths.length);
if (currentSlideNo %2 != 0) {
currentSlideNo -= 1;
}
}
nextSlide = Slide(currentNotebookNo, currentSlideNo);
//currentSlide = Slide(currentNotebookNo, currentSlideNo);
}

+ 16
- 0
Timer.pde Dosyayı Görüntüle

@@ -0,0 +1,16 @@
class Timer {
float time;
int starttime, lasttime;
Timer(float t) {
time = t;
starttime = second();
lasttime = starttime;
}
void update() {
if (millis() - starttime >= lasttime + time) {
lasttime = millis();
//runs once every time "time" (millis as float) passed:
nextSlide();
}
}
}

+ 65
- 0
notizheftanzeiger.pde Dosyayı Görüntüle

@@ -0,0 +1,65 @@
import java.util.*;

//////// Config

int mode = NORMAL; //NORMAL or RANDOM order
float timerTime = 5000; //in milliseconds how long slide is shown
float transitionTime = 3000; //how long it takes to fade the next slide in. must not be greater than "timerTime"
boolean displayText = true; //if the "date" should be written on screen
boolean displayTimeline = true; //if the timeline should be drawn on screen
boolean fullscreen = true;

//

Timer timer;
PImage currentSlide, nextSlide;
int currentNotebookNo, currentSlideNo;
int startTransitionTime;
float transitionProgress;
final static int NORMAL = 0;
final static int RANDOM = 1;


void setup() {
//fullScreen(); //if using fullScreen, comment the next line
size(960, 540);
fill(255);
if (displayTimeline) {
textSize(20);
textAlign(CENTER);
} else {
textSize(20);
}
timer = new Timer(timerTime);
createNotebooks();
currentSlide = Slide(currentNotebookNo, currentSlideNo);
//if (mode == RANDOM) nextSlide();
}

void draw() {
timer.update();
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) {
currentSlide = nextSlide;
transitionProgress = 0;
transition = false;
}
}

if (displayTimeline) {
stroke(255, 127);
strokeWeight(4);
line(50, height-30, width-50, height-30);
int xPos = (int)map(notebooks.get(currentNotebookNo).year, 1966, 2012, 50, width-50);
ellipse(xPos, height-30, 20, 20);
if (displayText) text(notebooks.get(currentNotebookNo).year, xPos, height-50);
} else {
if (displayText) text(notebooks.get(currentNotebookNo).dateText, 20, 40);
}
}

Loading…
İptal
Kaydet