Skip to content

Instantly share code, notes, and snippets.

@kadirmalak
Created March 4, 2018 16:43
Show Gist options
  • Save kadirmalak/c9ca28cb232f95db44b20fb2bd392996 to your computer and use it in GitHub Desktop.
Save kadirmalak/c9ca28cb232f95db44b20fb2bd392996 to your computer and use it in GitHub Desktop.
Minimal Processing app with Clojure
(ns processing-with-clojure.core
(:gen-class
:extends processing.core.PApplet) ;; we need a class extending processing.core.PApplet
(:import (processing.core PConstants PApplet)))
(defn -main
[& args]
(PApplet/main "processing_with_clojure.core")) ;; generated class name has underscores(_)
;; instead of hyphens(-)
(defn -settings [this] ;; override settings() method
(.size this 640 480 PConstants/P3D)) ;; equivalent of size(640, 480, P3D)
(defn -setup [this] ;; override setup() method
(.background this 255 255 255)) ;; equivalent of background(255, 255, 255)
(defn -draw [this] ;; override draw() method
(if (.-mousePressed this)
(.fill this 0)
(.fill this 255))
(let [x (.-mouseX this)
y (.-mouseY this)
width 80
height 80]
(.ellipse this x y width height)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment