Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no public this() method in the class de.looksgood.ani.Ani #18

Open
julsgud opened this issue Sep 27, 2016 · 7 comments
Open

There is no public this() method in the class de.looksgood.ani.Ani #18

julsgud opened this issue Sep 27, 2016 · 7 comments
Labels

Comments

@julsgud
Copy link

julsgud commented Sep 27, 2016

When using Ani in classes and using a bang() or similar method, the applet freezes on occasion. This happened in my own sketch but I was able to reproduce the error in the Ani_in_Classes_Bang example that comes with the library as well. The error is reported at the end of the bang method in the Cirlce class.

import de.looksgood.ani.*;

Cirlce cirlce;

void setup() {
  size(512, 512);
  smooth();
  noStroke();
  textAlign(CENTER);

  // Ani.init() must be called always first!
  Ani.init(this);
  cirlce = new Cirlce();
}

void draw() {
  background(255);
  cirlce.draw();
}

void keyReleased() {
  if (key == ' ') cirlce.bang();
}

class Cirlce {
  float x = random(0, width);
  float y = random(0, height);
  color c = color(0);

  Ani diameterAni;
  float diameterStart = 200;
  float diameterEnd = 5;
  float diameter = diameterStart;
  float duration = 0.9;

  Cirlce() {
    // diameter animation
    diameterAni = new Ani(this, duration, "diameter", diameterEnd);
    diameterAni.pause();
    diameter = diameterEnd;
  }

  void bang() {
    diameter = diameterStart;
    diameterAni.seek(0);
    diameterAni.resume();
'Ani_in_Classes_Bang:54:0:54:0: RuntimeException: There is no public this() method in the class de.looksgood.ani.Ani'
  }

  void draw() {
    fill(c);
    ellipse(x, y, diameter, diameter);
  }
}

Thanks!

@GoToLoop
Copy link

Apparently method resume() can't be invoked when the Ani isEnded().
Maybe replace pause() w/ end() and resume() w/ start()? 💡

@julsgud
Copy link
Author

julsgud commented Sep 28, 2016

You are right! The following works properly. The only downside is that you are are starting with the ended animation, which in some cases may be undesirable. Here is what works, does not throw previous error.

In constructor:

Cirlce() {
    // diameter animation
    diameterAni = new Ani(this, duration, "diameter", diameterEnd);
    diameterAni.end();
  }

Bang method:

void bang() {
    diameter = diameterStart;
    diameterAni.start();
  }

Thanks! The idea of using pause/resume/seek is great though, it helps you prep an Ani in the state that you want. Would be great to see that refactored to be able to restart when a Ani has ended.

@GoToLoop
Copy link

You can always check for isEnded() or isPlaying() before invoking resume(). 🌟

@b-g
Copy link
Owner

b-g commented Oct 4, 2016

Hi @julsgud Thanks for the bug report and pointer! I can confirm that this is a bug :( Will try to fix it with the next maintenance update (might take some time), as Ani is no longer heavily under development. P5js is the future! :) Please use in the meantime the workaround of @GoToLoop. Cheers! All the best, Benedikt

@julsgud
Copy link
Author

julsgud commented Oct 7, 2016

Hey @b-g! @GoToLoop 's workaround does the job pretty well! Great to hear you are placing your future bets on p5js. Any plans for an Ani for p5js? Would love to help/support making that happen. Woop! Best, Juls

@b-g
Copy link
Owner

b-g commented Oct 9, 2016

Hi @julsgud, Yes I think javascript is one of the main leads for the future of creative coding in terms of technicalities ... However there are so many animation libraries in javascript that I'm not convinced whether it is a good idea / worth the effort to port Ani to JS. Or what do you think?

https://github.com/tweenjs/tween.js/
https://greensock.com/tweenlite
https://github.com/juliangarnier/anime
...

@b-g b-g added the bug label Oct 9, 2016
@julsgud
Copy link
Author

julsgud commented Oct 9, 2016

Hey @b-g , I have to say I agree. It also seems that tween.js has a similar approach to Ani declarations, great to have that simplicity there too. Will start doing some tests to see how well they play with p5js. Thanks for sharing these!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants