extremely slow, smooth movement?
in
Contributed Library Questions
•
1 year ago
I'm working on an image viewer that will be similar to a screen saver. What I'm trying to do is move x/y coordinates on a PImage and maybe resize the image very, very gradually. My problem is that when I try to use fractions for x/y values, play with the framerates, and even use motion tweening libraries, the animation is jittery because it is so slow.
How can I achieve slow, gradual motion that is also smooth?
I'm using this animation library:
- import ijeoma.motion.Motion;
- import ijeoma.motion.tween.Tween;
- String title;
- PImage imageOTD;
- PFont font;
- PGraphics pg;
- float xPos=0;
- float yPos=0;
- Tween t;
- void setup() {
- size(1000, 700);
- background(0);
- noStroke();
- Motion.setup(this);
- t = new Tween("t",0f,width,6000f);
- t.play();
- // Load RSS feed
- String url = "http://www.nasa.gov/rss/lg_image_of_the_day.rss";
- XMLElement rss = new XMLElement(this, url);
- // Get title
- XMLElement[] titleXMLElements = rss.getChildren("channel/image/title");
- title = titleXMLElements[0].getContent();
- // Get image URL
- XMLElement[] imageXMLElements = rss.getChildren("channel/image/url");
- String imageURL = imageXMLElements[0].getContent();
- imageOTD=loadImage(imageURL);
- pg = createGraphics(width, height, JAVA2D);
- pg.beginDraw();
- pg.textFont(createFont("Franklin Gothic Heavy", 150, true));
- pg.textAlign(CENTER, CENTER);
- pg.background(0);
- pg.fill(255);
- pg.text(title, 0, -20, pg.width, pg.height);
- pg.smooth();
- pg.endDraw();
- frameRate(60);
- }
- void draw() {
- background(0);
- image(imageOTD,xPos,yPos);
- //if (frameCount % 1 == 0) {
- xPos=t.getPosition();
- yPos=t.getPosition();
- //}
- blend(pg, 0, 0, pg.width, pg.height, 0, 0, pg.width, pg.height, OVERLAY);
- }
1