[QUIL] select-input and select-output?

166 views
Skip to first unread message

Jay Porcasi

unread,
Apr 10, 2017, 11:49:09 PM4/10/17
to Clojure
hello,

i'm looking for the Quil equivalents of Processing selectInput() and selectOutput() but i can't find them

if they're not there, what would be the best way to directly access the corresponding Processing methods instead?
or is there a different more convenient way to get the same functionality of those methods?

thanks for any suggestions in the right direction
Jay

Nikita Beloglazov

unread,
Apr 12, 2017, 2:26:53 AM4/12/17
to Clojure
Hi Jay

No, there is no native support of selectInput() or selectOutput() in Quil. You can try calling Processing's methods directly using java interop. Though it's not straightforward. The problem is that when you call selectInput() you have to pass a name of callback function to be called. This name is just a string and Processing finds corresponding method using reflection and invokes it. To make it work we need to generate a class, let's say FileCallback which has method onFileSelected(). Then we need to pass instance of that class to selectInput() along with "onFileSelected" as callback name. 

Here is an example: https://gist.github.com/nbeloglazov/8a74fa3e6bbb44137df27c4a5201ad1e If you're not familiar with generating classes in clojure then check docs it's non-trivial. 

Hope this helps,
Nikita

Jay Porcasi

unread,
Apr 13, 2017, 9:20:21 AM4/13/17
to Clojure
thank you Nikita!

i will try your example to understand it better

a simple file chooser that returns the file path as string is all i need actually, i don't get all the complication in Processing of passing a callback function but i guess it must be there for a reason

cheers,
Jay

Jay Porcasi

unread,
Apr 16, 2017, 5:52:41 AM4/16/17
to Clojure
hello Nikita,
your example worked great!
and i was able to 'abstract' it into a select-input function that i can call to set the file-path
hopefully it will be straightforward to do the same for select-output and select-folder
by the way it would be great if something like that was available in quil by default
thank you a lot for your help,
Jay

Nikita Beloglazov

unread,
Apr 16, 2017, 6:07:56 PM4/16/17
to Clojure
Glad to hear you worked it out. Feel free to contribute your implementation of select-input/output/folder to Quil. 

Nikita

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/R61OvE4jYEc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jay Porcasi

unread,
Apr 19, 2017, 7:58:06 AM4/19/17
to Clojure
my 'implementation' is actually nothing more than a function that runs your code :-)
meaning that it relies on an AOT dependency in the project for the java class, which i don't mind in a personal project like mine, but probably wouldn't cut for Quil

moreover my initial goal was for the function to actually return the file path, but as the underlying code runs asynchronously, and after a few failed attempts with while loops, futures, promises... i had to rely on the 'global' atom instead as in your example
which again is not a big deal for me bacause i actually have a map to keep all the current events, and so i treat the file path as an 'event' of sort (file-input-selected, file-output-selected.. and so on, containing the file path as string) because i prefer 'polling' my map at each 'frame' instead of the event driven way of doing stuff

the reason why i prefer 'polling' to 'event driven' would be probably a bit convoluted to explain here, but it allows me to work in a truly modular way, where i can just write a new module for any change i want to make to the app, be it deleting, modifying or adding a new feature
call it 'additive' programming if you want
makes it easy to go back to previous versions, or to try new ideas, and generally keeps me sane while coding :-)

each module has the same structure of the whole app (each with its own :setup, :update, :draw, etc.) and gets 'compiled' (by a macro) to a plain middleware

and Quil middleware functionality is pure genius
Reply all
Reply to author
Forward
0 new messages