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

feature request: with-sketch in clojure. #187

Closed
magnetophon opened this issue Aug 5, 2016 · 7 comments
Closed

feature request: with-sketch in clojure. #187

magnetophon opened this issue Aug 5, 2016 · 7 comments

Comments

@magnetophon
Copy link

I'm a total clojure newbie,but already love quil

Afaict there is no way of controlling sketch outside sketch code.
See this.

I'd like to be able to have overtone events trigger drawing.

@nbeloglazov
Copy link
Member

Actually, there is a way. You can use

(quil.applet/with-applet my-sketch
  (ellipse 100 100 100 100))

It's kinda "internal" because it's not in quil.core but should work. And I guess it makes sense to make it public as with-sketch. Would you be interested in adding it?

@magnetophon
Copy link
Author

@nbeloglazov
Thanks, I'll try that.
What do you mean by ''Would you be interested in adding it?''

@nbeloglazov
Copy link
Member

I mean that quil.applet/with-applet is "private" I think it should be public by adding it to quil.core/with-sketch. This way with-sketch is going to work both in clojure and clojurescript.

@magnetophon
Copy link
Author

@nbeloglazov Sounds good to me!

@nbeloglazov
Copy link
Member

I tried to implement with-sketch for clojure but failed. Nothing was drawn on a sketch. I believe Processing doesn't support drawing outside of "draw" function. After draw is called processing disposes graphics object and if we try to draw on it from another thread using with-sketch nothing will happen. It silently ignores all draw operations.

Some other lifecycle functions like start-loop and no-loop might still work but it doesn't feel right to support with-sketch if only limited number of functions are going to work. I'm closing this issue as "not feasible". If anyone has ideas how to fix it - feel free to reopen.

@nbeloglazov
Copy link
Member

So the only possible way from some other code (like overtone) to write something is to save data into an atom and have sketch draw function read this data and draw. There might be small lag between overtone updating atom and sketch drawing it, but given that FPS is pretty high 30-60, the lag should be hardly noticeable.

@magnetophon
Copy link
Author

Thanks for looking in to it, and for providing a workaround.

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

No branches or pull requests

2 participants