mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
moving the rest of the video examples
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Loop.
|
||||
*
|
||||
* Move the cursor across the screen to draw.
|
||||
* Shows how to load and play a QuickTime movie file.
|
||||
*/
|
||||
|
||||
import processing.video.*;
|
||||
|
||||
Movie myMovie;
|
||||
|
||||
void setup() {
|
||||
size(640, 480, P2D);
|
||||
background(0);
|
||||
// Load and play the video in a loop
|
||||
myMovie = new Movie(this, "station.mov");
|
||||
myMovie.loop();
|
||||
}
|
||||
|
||||
void movieEvent(Movie myMovie) {
|
||||
myMovie.read();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
tint(255, 20);
|
||||
image(myMovie, mouseX-myMovie.width/2, mouseY-myMovie.height/2);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* Pixelate
|
||||
* by Hernando Barragan.
|
||||
*
|
||||
* Load a QuickTime file and display the video signal
|
||||
* using rectangles as pixels by reading the values stored
|
||||
* in the current video frame pixels array.
|
||||
*/
|
||||
|
||||
|
||||
import processing.video.*;
|
||||
|
||||
int numPixels;
|
||||
int blockSize = 10;
|
||||
Movie myMovie;
|
||||
color myMovieColors[];
|
||||
|
||||
void setup() {
|
||||
size(640, 480, P2D);
|
||||
noStroke();
|
||||
background(0);
|
||||
myMovie = new Movie(this, "station.mov");
|
||||
myMovie.loop();
|
||||
numPixels = width / blockSize;
|
||||
myMovieColors = new color[numPixels * numPixels];
|
||||
}
|
||||
|
||||
// Read new values from movie
|
||||
void movieEvent(Movie m) {
|
||||
m.read();
|
||||
m.loadPixels();
|
||||
|
||||
for (int j = 0; j < numPixels; j++) {
|
||||
for (int i = 0; i < numPixels; i++) {
|
||||
myMovieColors[j*numPixels + i] = m.get(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Display values from movie
|
||||
void draw() {
|
||||
for (int j = 0; j < numPixels; j++) {
|
||||
for (int i = 0; i < numPixels; i++) {
|
||||
fill(myMovieColors[j*numPixels + i]);
|
||||
rect(i*blockSize, j*blockSize, blockSize-1, blockSize-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* Drawing Movie.
|
||||
*
|
||||
* Makes a QuickTime movie of a line drawn by the mouse. Press
|
||||
* the spacebar to finish and save the movie.
|
||||
*/
|
||||
|
||||
import processing.video.*;
|
||||
|
||||
MovieMaker mm;
|
||||
|
||||
void setup() {
|
||||
size(320, 240);
|
||||
|
||||
// Save uncompressed, at 15 frames per second
|
||||
mm = new MovieMaker(this, width, height, "drawing.mov");
|
||||
|
||||
// Or, set specific compression and frame rate options
|
||||
//mm = new MovieMaker(this, width, height, "drawing.mov", 30,
|
||||
// MovieMaker.ANIMATION, MovieMaker.HIGH);
|
||||
|
||||
background(160, 32, 32);
|
||||
}
|
||||
|
||||
|
||||
void draw() {
|
||||
stroke(7, 146, 168);
|
||||
strokeWeight(4);
|
||||
|
||||
// Draw if mouse is pressed
|
||||
if (mousePressed && pmouseX != 0 && mouseY != 0) {
|
||||
line(pmouseX, pmouseY, mouseX, mouseY);
|
||||
}
|
||||
|
||||
// Add window's pixels to movie
|
||||
mm.addFrame();
|
||||
}
|
||||
|
||||
|
||||
void keyPressed() {
|
||||
if (key == ' ') {
|
||||
// Finish the movie if space bar is pressed
|
||||
mm.finish();
|
||||
// Quit running the sketch once the file is written
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user