Upped Processing.js to 1.3.6, plus fixes to examples for 1.3.6

This commit is contained in:
fjenett
2011-11-06 11:44:43 +00:00
parent 40a2e4f0cc
commit f8c43eb3a6
6 changed files with 5625 additions and 15197 deletions

View File

@@ -24,7 +24,7 @@
if ( video != null )
{
PImage frame = getFrame(video);
PImage frame = video.getFrame();
float br = 0;
color px;
for ( int ix = 0; ix < frame.width; ix += 7 )
@@ -53,9 +53,10 @@
{
if ( video != null )
{
// this currently does not work for chrome with our server
video.currentTime = map(constrain(mouseX,0,width-10),0,width-10,0,video.duration);
wasDragged = true;
video.pause();
wasDragged = true;
}
}
@@ -77,12 +78,6 @@
video = v;
}
/* copy video image to PImage */
PImage getFrame ( Video v )
{
return new PImage(v); // sub-optimal ..
}
/* make Processing understand the HTMLVideoElement */
interface Video
{

View File

@@ -6,6 +6,13 @@ window.onload = function () {
var sketch = Processing.instances[0];
if ( sketch == undefined )
return setTimeout(tryFindSketch, 200); // retry in 0.2 secs
// extending our HTMLVideoElement object to return a PImage
video['getFrame'] = function () {
var img = new sketch.PImage;
img.fromHTMLImageData(video);
return img;
};
(function( s, v ){
var tryAddVideo = function () {
@@ -19,6 +26,8 @@ window.onload = function () {
})( sketch, video );
}
// looping currently not working in chrome as our internal server does
// not support http byte ranges
addEvent(video,'ended',function(){
if ( 'loop' in this && this.loop ) {
this.currentTime = 0;

View File

@@ -41,7 +41,7 @@
timeLineEffects();
PImage frame = getFrame(video);
PImage frame = video.getFrame();
PImage rgbImage = frame.get(frame.width/2,0,frame.width/2,frame.height);
PImage maskImage = frame.get(0,0,frame.width/2,frame.height);
rgbImage.mask(maskImage);
@@ -65,12 +65,6 @@
video = v;
}
/* copy video image to PImage */
PImage getFrame ( Video v )
{
return new PImage(v); // sub-optimal ..
}
/* make Processing understand the HTMLVideoElement */
interface Video
{

View File

@@ -20,6 +20,13 @@ function initVideos ( sketch ) {
video['loop'] = true; // as "loop" is not supported by many browsers
// extending our HTMLVideoElement object to return a PImage
video['getFrame'] = function () {
var img = new sketch.PImage;
img.fromHTMLImageData(video);
return img;
};
// similar to tryFindSketch this creates a loop that
// continues until the video becomes ready.
(function( s, v ){

View File

@@ -10,8 +10,6 @@
HashMap<Integer,FImage> fImages;
HashMap<Integer,PImage> images;
PImage selectedImage;
int scrollY=0;
int w75;
@@ -32,17 +30,13 @@
{
translate(0,scrollY);
PImage[] imgs = images.values();
for ( int i = 0; i < imgs.length; i++ )
Iterator imgs = images.values().iterator();
int i = 0;
while ( imgs.hasNext() )
{
image(imgs[i], int(i%w75)*75, int(i/w75)*75);
if ( selectedImage != null && selectedImage == imgs[i] )
{
fill(255,50);
noStroke();
rect( int(i%w75)*75, int(i/w75)*75, 75,75 );
}
PImage img = imgs.next();
image(img, int(i%w75)*75, int(i/w75)*75);
i++;
}
}
else
@@ -65,15 +59,8 @@
pScrollY = scrollY;
}
void mouseMoved ()
{
selectImage();
}
void mouseDragged ()
{
selectImage();
if ( images != null && images.size() > 0 )
{
int newScrollY = pScrollY + (mouseY-pressedY);
@@ -84,18 +71,6 @@
}
}
void selectImage ()
{
int selectX = int(mouseX/75);
int selectY = int((mouseY + -scrollY) / 75);
int s = selectX + selectY*w75;
if ( s >= 0 && s < images.size() )
{
selectedImage = images.values()[s];
}
}
void resetFlickrImages ()
{
if ( images != null )
@@ -109,7 +84,6 @@
fImages = new HashMap<Integer,FImage>();
scrollY = 0;
selectedFImage = null;
}
void newFlickrImage ( FImage fi )