Skip to content

Instantly share code, notes, and snippets.

@nbeloglazov
Last active April 12, 2017 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbeloglazov/8a74fa3e6bbb44137df27c4a5201ad1e to your computer and use it in GitHub Desktop.
Save nbeloglazov/8a74fa3e6bbb44137df27c4a5201ad1e to your computer and use it in GitHub Desktop.
Example of using Processing.selectInput() from Quil.
(defproject test "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[quil "2.6.0"]]
:aot [example.file-callback])
(ns example.core
(:require [quil.core :as q]
[quil.applet :as applet]
[quil.middleware :as m]))
(def file (atom nil))
(defn draw []
(q/background 255)
(q/fill 0)
(q/text (str "File: " (or @file "nil")) 20 20))
(defn file-selected [new-file]
(reset! file new-file))
(defn setup []
(.selectInput (applet/current-applet) "Choose a file" "onFileSelected" nil
(example.FileCallback. file-selected)))
(q/defsketch my-sketch
:draw draw
:size [500 500]
:setup setup)
(ns test.file-callback
(:gen-class
:name test.FileCallback
:main false
:state callback
:init init
:prefix "-"
:constructors {[java.lang.Object] []}
:methods [[onFileSelected [java.io.File] void]]))
(defn -init [callback]
[[] callback])
(defn -onFileSelected [this file]
((.callback this) file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment