We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import processing.serial.*;
int slideStep = 75;
PImage currentImage, nextImage;
int imgIndex = 0;
int slideOffset;
String[] fileList ;
Serial myPort;
class FilterImages implements java.io.FilenameFilter
{
public boolean accept(File dir, String fname)
{
String[] extensions = {".png", ".jpeg", ".gif", ".tga", ".jpg"};
for (int i = 0; i < extensions.length; i++) {
if (fname.toLowerCase().endsWith( extensions[i]))
{
return true;
}
}
return false;
}
}
void loadFileNames()
{
java.io.File dir = new java.io.File(dataPath(""));
fileList = dir.list(new FilterImages());
}
void setup()
{
size(displayWidth, displayHeight);
loadFileNames();
imageMode(CENTER);
currentImage = loadImage(dataPath("") + fileList[0]);
currentImage.resize(0, height);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
}
void advanceSlide() {
imgIndex++;
if (imgIndex >= fileList.length) {
imgIndex = 0;
}
slideOffset = width;
}
void reverseSlide() {
imgIndex--;
if (imgIndex < 0) {
imgIndex = fileList.length - 1;
}
slideOffset = width * - 1;
}
void draw() {
background(0);
image(currentImage, width/2, height/2);
if (slideOffset != 0) {
image(nextImage, slideOffset + width/2, height/2);
if (slideOffset > 0) {
slideOffset -= slideStep;
if (slideOffset < 0) {
slideOffset = 0;
}
}
if (slideOffset < 0) {
slideOffset += slideStep;
if (slideOffset > 0) {
slideOffset = 0;
}
}
if (slideOffset == 0) {
currentImage = nextImage;
}
}
else {
if (myPort.available() > 0) {
char inByte = myPort.readChar();
print(inByte);
if (inByte == 'F') {
advanceSlide();
}
if (inByte == 'B') {
reverseSlide();
}
nextImage = loadImage(dataPath("") + fileList[imgIndex]);
nextImage.resize(0, height);
}
}
}
Answers
edit post, highlight code, press ctrl-o
what line is the error on?
error on line 59 and line 62. Thanks
Don't post pictures, they are unreadable.
line 46 and 49