We are about to switch to a new forum software. Until then we have removed the registration on this forum.
The following code is from the book and is untouched -- it will not run. It says it is for Processing 1.2, and I've looked to see if there is anything weird, and I don't see anything. But, I have limited knowledge at this point and can only check that function descriptions haven't changed. I would really like to see this thing run. Ideas appreciated! (Runs neither under Java or JS in the Processing sketch window and I've tried it with both 2.02 and 2.03.) (And, I put station.mov in the same directory and in a data folder.) There are no errors, and the sketch window does come up, but remains blank.
/**
* Transform: Slit-Scan
* from Form+Code in Design, Art, and Architecture
* by Casey Reas, Chandler McWilliams, and LUST
* Princeton Architectural Press, 2010
* ISBN 9781568989372
*
* This code was written for Processing 1.2+
* Get Processing at http://www.processing.org/download
*/
import processing.video.*;
Movie myVideo;
int video_width = 160;
int video_height = 120;
int video_slice_x = video_width/2;
int window_width = 1000;
int window_height = video_height;
int draw_position_x = 0;
boolean newFrame = false;
void setup() {
myVideo = new Movie(this, "station.mov");
size(window_width, window_height, P2D);
background(0);
myVideo.loop();
}
void movieEvent(Movie myMovie) {
myMovie.read();
newFrame = true;
}
void draw() {
if (newFrame) {
loadPixels();
for (int y=0; y<window_height; y++){
int setPixelIndex = y*window_width + draw_position_x;
int getPixelIndex = y*video_width + video_slice_x;
pixels[setPixelIndex] = myVideo.pixels[getPixelIndex];
}
updatePixels();
draw_position_x++;
if (draw_position_x >= window_width) {
exit();
}
newFrame = false;
}
}
Answers
P2D in Processing 2+ is completely different from P2D from older versions!!! :O
P2D now uses OpenGL. But in older days, it was a very fast 2D engine! :o3
Anyways, dunno if that's the real problem you've got there! 8-|
Double bad practice: size() should be the first call, and no need to create variables to hold dimensions, Processing has them already:
and remove the window_width and window_height variable declarations, and use width and height variables where they are used.
@PhiLho - I know about putting the size first, BUT because this was a Reas sketch, AND the sketch uses 2 windows -- the little one to play the video and the wide, skinny one to display the scan, I didn't touch that. (Because I don't yet know anything about using 2 windows!)
@GoToLoop - turns out that was it. I just removed the P2D and the sketch works as it is supposed to.
to BOTH of you: what I find interesting is that the little window in which the movie plays, does not show up at all while the slits are being taken and written to the wide window.
Well, beware of old code. Perhaps such practice was OK in the past, but in recent versions of Processing, it can make, in non-default renderers, to load the file twice, which can take some time if the movie is big!
About the two windows: not sure what the code is, but if there is not two threads (one per window), I can understand one being stuck when the other do stuff.
This is how I suggest writing the code in a way that remains true to the original:
The addition of line 36 is what made it work again. This line should have been in the original, so it's not an issue with 2.0+, it was an issue with the original code.
Thank you so much Mr. @Reas. As you can see from the above comments, I did get it to run.
And, of course, your new code works as well. So that is what I am working with now.
If I may venture one more question: I am trying to get this to generate on the web, and while the new code at least brings up the window, I do get the following error:
I realize this may be a complex issue -- but if you could just point me in right direction to look for the solution, I would be most grateful. "Movie not found", I would understand, however, "Movie not defined" puts me at a loss.
I am an artist who has long been a "junior programmer". I thank you so much for this language.
It means the program doesn't know what a Movie is. :-SS
If that is a data-type, you need the class which implements it! :-\"
And if that class happens to belong to a Java library import, you need a JS version of it!!! :O
You have to explore the ProcessingJS site to see if movies are supported at all. HTML5 supports movies but I don't know if PJS supports them.
Thanks @PhiLho -- I'll go there again and see if I missed anything. After I researched there I put a long (long) post about this in the JavaScript forum because that's where I thought it might belong. There haven't been any comments so I'll check the processingJS one more time.
BUT, I am about to give up on this aspect of Processing because it seems I am spending more time mucking about with getting things to work on the web than I am working on my ideas! Since I'm old, this is not the way I want to spend what little time I have left!!! So, from now on if they run on the web, they run, if not, I put up a still image. I would rather develop my skills in Processing, not in moving furniture. Still, it drives me crazy!
@clair -> some useful posts from PJS Google group:
https://groups.google.com/forum/#!topic/processingjs/uKwpxZoaXbA
https://groups.google.com/forum/#!topic/processingjs/9Zv_QGnM2bg
@GoToLoop - I had already been through those resources and while I got some ideas, the examples were so thoroughly complicated with audio and controls (esp. the latter) it was impossible to sort out the stuff I needed from the code.
However, I also went to openprocessing.org and spent about an hour there -- everything, and I do mean everything, with a Movie call in the sketch did not run. I checked out at least 50 that had a call to Movie in them and NONE worked.
This must be a hugely difficult problem or at least some of the sketches I played would have run.
I am pretty sure that one of the major issues is the fact that the Processing variable Movie is not recognized and video - which is recognized is also the name of the Processing library. Seems that this makes for a rock and a hard place.
I am fairly smart -- and if there were ONE just one simple example of a .mov, .mp4, .anything playing in a processing sketch on the web, I could sort it out.
My last effort on this is going to be a blunt question in the How to ... section of the forum here. If there are no answers there, then that's the end of it. I've had it up to my eyeballs with this -- and this has nothing to do with Processing itself, or with creating art. So, I'm at the point where all time on this is just wasted.
But if you ever, ever, run across a sketch that does play a movie from a processing sketch that is on the web, please remember me and email me the link!!
Thanks much, GoTo! Cheers, Clair