We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › 1920x1080 smooth image tween
Page Index Toggle Pages: 1
1920x1080 smooth image tween (Read 1094 times)
1920x1080 smooth image tween
Mar 16th, 2010, 4:26am
 
Hello All,

Pretty fresh to Processing and so I have what will probably be a simple question.

I have an application that I have built entirely in jquery and it works pretty good considering its in the browser. Basically its a image slide show but using images that are 1920x1080, images consist of lots of triptychs that are placed on a canvas by the user. This designer component works fine in a browser, its the slideshow that could be better.

Having said that, its animation is better than I can get things happening in Processing.

Here is my basic sketch, I'm really just trying to establish if Processing will be a better alternative or whether I should start working on optimisations of jquery animations or go to something like openFrameworks.

So, here is my sketch:

Code:

import megamu.shapetween.*;
PImage img;
Tween ani;

void setup() {
   size(1920, 1080);
   frameRate(30);
   
   img = loadImage("/path/to/images/29415.jpg");
       
   ani = new Tween(this, 30, Tween.SECONDS, Shaper.LINEAR);
   ani.start();
}

void draw() {
   background(0);
   ani.tick();
   
   set(int(ani.position() * width), 326, img);
}


So, basically I want this to move across the screen, which it does, but its very jumpy, much more jumpy that I have it operating in the browser using jquery, so it makes me think that perhaps I'm missing something...

I have also tried doing other things, such as using image instead of set.

Other things I want to do include zooming in on an image, which I also have had working, however again its jumpy.

Thanks in advance.
Alex
Re: 1920x1080 smooth image tween
Reply #1 - Mar 16th, 2010, 5:06am
 
Perhaps try in OpenGL mode?
By default, Processing moves the image by manipulating lot of pixels, which is slow even on modern computers.
I guess the browser uses some optimized code leveraging the graphics card capabilities, hence my suggestion to use OpenGL mode which should delegate the image drawing/moving to the card.

You mention openFrameworks, but I doubt it will work on the browser. Not without a plugin users would have to add.
Well, with Processing, users must have a recent Java installation, but it is still more probable (and generic) than having this plugin... Smiley
Re: 1920x1080 smooth image tween
Reply #2 - Mar 16th, 2010, 5:14am
 
Sorry to clarify the slideshow, for the moment, does not have to run in the browser. I did originally want it to run in a browser, however I can live without that for the time being as it just has to go up on a display at a gallery.

Thanks for the suggestion re OpenGL I'll have a look into that.
Re: 1920x1080 smooth image tween
Reply #3 - Mar 16th, 2010, 2:32pm
 
Thanks PhiLho, using OpenGL did the trick Smiley

Updated the code looks as follows.

Code:

import processing.opengl.*;
import megamu.shapetween.*;
PImage img;
Tween ani;

void setup() {
   size(1920, 1080, OPENGL);
   frameRate(30);
   
   img = loadImage("/path/to/images/29415.jpg");
       
   ani = new Tween(this, 30, Tween.SECONDS, Shaper.LINEAR);
   ani.start();
}

void draw() {
   background(0);
   ani.tick();
   
   set(int(ani.position() * width), 326, img);
}
Page Index Toggle Pages: 1