GithubHelp home page GithubHelp logo

quil / quil Goto Github PK

View Code? Open in Web Editor NEW
2.9K 2.9K 163.0 10.98 MB

Main repo. Quil source code.

License: Eclipse Public License 1.0

GLSL 0.45% Clojure 98.74% CSS 0.15% HTML 0.48% Emacs Lisp 0.04% Shell 0.14%

quil's Introduction

Quil

Clojars Version Github Test Results

http://quil.info

Quil Painting

Quil looked up in shock to see Bigelow floating high in the clouds, his balloons rustling merrily in the wind. He gruffed to her from above, "This truly is a party!". Image after image, vista after vista, passed furry Bige's wide-open eyes. A deep underlying beauty unfolded before him. A flock of bezier gulls whistled past. Beneath his dangling paws a distant shepherd called his scribbly sheep in for re-sketching. Goading him from the distance, wooden letters of so many different fonts mocked PERLIN-WOULD from the hilltops.

This truly was an amazing place. Here, dreams and reality had been drawn together - all in one Process. "_Why would I ever leave?" he barked with joy! _Why indeed!

(mix Processing Clojure)

In one hand Quil holds Processing, a carefully crafted API for making drawing and animation extremely easy to get your biscuit-loving chops around. In the other she clutches Clojure, an interlocking suite of exquisite language abstractions forged by an army of hammocks and delicately wrapped in flowing silky parens of un-braided joy.

In one swift, skilled motion, Quil throws them both high into the air. In a dusty cloud of pixels, they bond instantly and fly off into the distance painting their way with immutable trails of brilliant colour. Moments later, you see them swiftly return and hover nearby. Your very own ride to Perlinwould awaits. Summon the winds and ride well, my friend.

Requirements

Quil works with Clojure 1.10 and ClojureScript 1.10.x.

Current released version 4.3.1560 is compatible JDK 17+ and supports Linux amd64,aarch64 and macOS M1/M2/x86_64 architectures.

Installation

Create sample project using a Leiningen Quil Template:

lein new quil hello-quil

Then go to hello-quil/src/hello-quil/core.clj file and run it!

There are also deps-new templates available for creating a sketchbook with the Clojure CLI.

If you like adding libraries manually - you simply need to add Quil as a dependency to project.clj:

[quil "4.3.1563"]

or for Clojure CLI deps.edn

quil/quil {:mvn/version "4.3.1563"}

Then to pull in all of Quil's silky goodness, just add the following to your ns declaration:

(:require [quil.core :as q])

For more detailed instructions head over to the wiki.

Getting Started

Using Quil is as easy as eating chocolate digestives. You just need to grok three basic concepts:

  • The Setup fn
  • The Draw fn
  • The Sketch

If setup and draw are hard working artistic gladiators, sketch is the arena in which they battle for the glory of art. However, they don't actually fight each other - they work as a team - relentlessly spilling colour all over the arena sands. The crowds roar for messy fight.

setup lays all the groundwork and is called only once at the start. draw, on the other hand, is called immediately after setup has completed, and then repeatedly until you summon it to stop. When you create a sketch and name your setup and draw fns, the fun automatically starts.

A simple example is called for:

(ns for-the-glory-of-art
  (:require [quil.core :as q]))

(defn setup []
  (q/frame-rate 1)                    ;; Set framerate to 1 FPS
  (q/background 200))                 ;; Set the background colour to
                                      ;; a nice shade of grey.
(defn draw []
  (q/stroke (q/random 255))             ;; Set the stroke colour to a random grey
  (q/stroke-weight (q/random 10))       ;; Set the stroke thickness randomly
  (q/fill (q/random 255))               ;; Set the fill colour to a random grey

  (let [diam (q/random 100)             ;; Set the diameter to a value between 0 and 100
        x    (q/random (q/width))       ;; Set the x coord randomly within the sketch
        y    (q/random (q/height))]     ;; Set the y coord randomly within the sketch
    (q/ellipse x y diam diam)))         ;; Draw a circle at x y with the correct diameter

(q/defsketch example                  ;; Define a new sketch named example
  :title "Oh so many grey circles"    ;; Set the title of the sketch
  :settings #(q/smooth 2)             ;; Turn on anti-aliasing
  :setup setup                        ;; Specify the setup fn
  :draw draw                          ;; Specify the draw fn
  :size [323 200])                    ;; You struggle to beat the golden ratio

Oh so many grey cicles

Feast your eyes on this beauty.

You're witnessing setup, settings, draw and sketch working in complete harmony. See how settings turns on anti-aliasing, setup sets the framerate to 1 FPS and sets the background colour to a nice shade of grey. draw then kicks into action. It chooses random stroke, fill colours as well as a random stroke weight (thickness of the pen). It then chooses some random coordinates and circle size and draws an ellipse. An ellipse with the same height and width is a circle. Finally defsketch a convenience macro around sketch ties everything together, specifies a title and size and starts things running. Don't just watch it though, start modifying it to see immediate effects. Go to town.

ClojureScript

Quil supports ClojureScript! Check wiki article for more info.

Documentation

For up-to-date documentation please check API page on quil.info.

When getting started with Quil, it's always useful to have the Cheatsheet handy. It may be a little bit out-dated but still contains most functions.

If you're new to Processing and graphics programming in general, the tutorials on Processing.org will get you started in no time.

Check Quil wiki for more documentation.

Examples

Wave Clock

Quil comes chock-packed full of examples covering most of the available API. Many of them have been translated from the excellent book "Generative Art" by Matt Pearson, with kind permission from the author.

Head over to the Gen Art Examples Page. Instructions of how to run examples you can find in README in Quil examples repo.

Also check out awesome gallery of sketches contributed by community members: http://quil.info/examples

Processing Compatibility

Quil provides support for the standard Processing API - currently Processing 4.3 and p5js 1.7.0. The majority of Processing methods have an equivalent Quil fn. Typically, camelCased methods have been converted to hyphenated-versions.

Community

You can ask questions, get support on our mailing list:

https://groups.google.com/forum/?fromgroups#!forum/clj-processing

There are a small number of people that hang out in #quil on freenode or #quil on the ClojureVerse slack. New artworks are show-cased on the @quilist Twitter account: http://twitter.com/quilist

Developing (leiningen)

Modifying Quil and testing changes is pretty simple. First run lein compile to compile some java classes. Then depending on whether you want to test Clojure or ClojureScript:

Clojure

  • If use emacs+cider, open dev/sample.clj and evaluate.
  • Alternatively run lein run -m sample which runs the sketch from dev/sample.clj.

ClojureScript

  • Run lein with-profile cljs-testing cljsbuild auto development which compiles Quil to JS and also compiles a sample sketch in dev/sample.cljs.
  • Run python -m SimpleHTTPServer (Python 2) or python -m http.server (Python 3) to start local static server. Open http://localhost:8000/dev/index.html.
  • Alternatively, if you don't have python, open dev/index.html page from browser. It should work as well.

In ClojureScript all changes to cljs files (e.g. dev/sample.cljs or src/cljs/...) will be automatically recompiled. You just need to refresh the page.

Developing (deps.edn)

  • Install clojure-cli and babashka.
  • bb processing-install will download a local copy of the upstream processing4 release. It will also unpack the architecture specific jar files into the right places for the deps.edn :local/root dependencies to find.
  • clojure -T:build aot will do an Ahead of Time compilation of a few classes required to interface with Processing.

Important because of the dependency on Processing jars which are not hosted in any maven repository, it is not currently possible to use quil as a :git/sha coordinate dependency.

Run automated tests locally for clj or cljs with:

  • clojure -Mdev:kaocha unit clj-snippets for clj tests
  • clojure -Mdev:fig:kaocha cljs-snippets for cljs snippet tests (requires chromedriver)
  • clojure -Mfig:cljs-test for cljs tests

The coverage from the tests in the leiningen environment are still higher, but are being migrated over to automated tests that can run on Github Actions.

To develop with clj using emacs and the cider repl, use C-u M-x cider-jack-in-clj, then select clojure-cli and append :dev to the list of -M aliases. This ensures that "test" is in the classpath along with testing dependencies, so that it's possible to evaluate tests at the repl.

License

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

The official Processing.org's jars, used as dependencies, are distributed under LGPL and their code can be found on http://processing.org/

Contributors

See list of contributors.

quil's People

Contributors

alex-keyes avatar andrewvc avatar anthonygalea avatar aperiodic avatar asifm avatar astanin avatar blak3mill3r avatar dgtized avatar dominicfreeston avatar erikedin avatar flazz avatar ilya-epifanov avatar jackrusher avatar janiczek avatar llasram avatar nbeloglazov avatar nightmachinery avatar norgat avatar pggb avatar plexus avatar prakhar1989 avatar pxlpnk avatar rosado avatar samaaron avatar satchit8 avatar severeoverfl0w avatar shrynx avatar superquadratic avatar technomancy avatar ztellman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quil's Issues

recurring OpenGL renderer error

Any sketch with :renderer :opengl will sporadically throw the following error. I haven't been able to isolate exactly what conditions cause it other than an OpenGL renderer.

full traceback:

java.lang.IllegalArgumentException: GLDrawableFactory.chooseGraphicsConfiguration() was not used when creating this Component
    at com.sun.opengl.impl.x11.X11GLDrawableFactory.getGLDrawable(X11GLDrawableFactory.java:238)
    at processing.opengl.PGraphicsOpenGL.allocate(PGraphicsOpenGL.java:283)
    at processing.core.PGraphics3D.setSize(Unknown Source)
    at processing.core.PApplet.makeGraphics(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.makeGraphics(Unknown Source)
    at processing.core.PApplet.size(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.size(Unknown Source)
    at processing.core.PApplet.size(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.size(Unknown Source)
    at quil.applet$applet_set_size.invoke(applet.clj:130)
    at clojure.lang.AFn.applyToHelper(AFn.java:167)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.core$apply.invoke(core.clj:600)
    at quil.applet$applet$setup_fn__162.invoke(applet.clj:237)
    at quil.applet$applet$fn__250.invoke(applet.clj:346)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.seu at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.seu at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.setup(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)
Exception in thread "Animation Thread" java.lang.RuntimeException: processing.opengl.PGraphicsOpenGL needs to be updated for the current release of Processing.
    at processing.core.PApplet.makeGraphics(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.makeGraphics(Unknown Source)
    at processing.core.PApplet.size(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.size(Unknown Source)
    at processing.core.PApplet.size(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.size(Unknown Source)
    at quil.applet$applet_set_size.invoke(applet.clj:130)
    at clojure.lang.AFn.applyToHelper(AFn.java:167)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.core$apply.invoke(core.clj:600)
    at quil.applet$applet$setup_fn__162.invoke(applet.clj:237)
    at quil.applet$applet$fn__250.invoke(applet.clj:346)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.setup(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)

error running clojure 1.3

Hi sam..I had problems running quil using clojure 1.3...I had change this to clojure 1.2.1...this is the error

lein swank
Warning: log-events not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic log-events or change the name.
Warning: log-output not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic log-output or change the name.
Warning: namespace-re not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic namespace-re or change the name.
Warning: current-connection not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic current-connection or change the name.
Warning: default-encoding not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic default-encoding or change the name.
Warning: pre-reply-hook not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic pre-reply-hook or change the name.
Warning: pre-reply-hook not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic pre-reply-hook or change the name.
Warning: thread-map-next-id not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic thread-map-next-id or change the name.
Warning: thread-map-next-id not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic thread-map-next-id or change the name.
Warning: thread-map not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic thread-map or change the name.
Warning: thread-map not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic thread-map or change the name.
Warning: mailboxes not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic mailboxes
or change the name.
Warning: mailboxes not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic mailboxes
or change the name.
Warning: protocol-version not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic protocol-version or change the name.
Warning: protocol-version not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic protocol-version or change the name.
Warning: current-package not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic current-package or change the name.
Warning: pending-continuations not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic
pending-continuations or change the name.
Warning: sldb-stepping-p not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic sldb-stepping-p or change the name.
Warning: sldb-initial-frames not declared dynamic and thus is not dynamically
rebindable, but its name suggests otherwise. Please either indicate ^:dynamic sldb-initial-frames or change the name.
Warning: sldb-level not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic sldb-level or change the name.
Warning: sldb-restarts not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic sldb-restarts or change the name.
Warning: debug-swank-clojure not declared dynamic and thus is not dynamically
rebindable, but its name suggests otherwise. Please either indicate ^:dynamic debug-swank-clojure or change the name.
Warning: active-threads not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic active-threads or change the name.
Warning: active-threads not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic active-threads or change the name.
Warning: debug-quit-exception not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic debug-quit-exception or change the name.
Warning: debug-quit-exception not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic debug-quit-exception or change the name.
Warning: debug-continue-exception not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic debug-continue-exception or change the name.
Warning: debug-continue-exception not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic debug-continue-exception or change the name.
Warning: debug-abort-exception not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic
debug-abort-exception or change the name.
Warning: debug-abort-exception not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic
debug-abort-exception or change the name.
Warning: current-exception not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic current-exception or change the name.
Warning: current-env not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic current-env or change the name.
Warning: connections not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic connections or change the name.
Warning: connections not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic connections or change the name.
Warning: compiler-exception-location-re not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic compiler-exception-location-re or change the name.
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: print-doc in this context, compiling:(swank/commands/basic.clj:180)
at clojure.lang.Compiler.analyze(Compiler.java:6235)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3452)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6411)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572)
at clojure.lang.Compiler$TryExpr$Parser.parse(Compiler.java:2091)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6409)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5873)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6409)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6397)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6397)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5873)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6409)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6397)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6397)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5008)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3629)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6407)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6397)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:492)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6409)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler.eval(Compiler.java:6469)
at clojure.lang.Compiler.load(Compiler.java:6902)
at clojure.lang.RT.loadResourceScript(RT.java:357)
at clojure.lang.RT.loadResourceScript(RT.java:348)
at clojure.lang.RT.load(RT.java:427)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5275)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$require.doInvoke(core.clj:5352)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at swank.swank$eval35$loading__4505__auto____36.invoke(swank.clj:11)
at swank.swank$eval35.invoke(swank.clj:11)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6455)
at clojure.lang.Compiler.load(Compiler.java:6902)
at clojure.lang.RT.loadResourceScript(RT.java:357)
at clojure.lang.RT.loadResourceScript(RT.java:348)
at clojure.lang.RT.load(RT.java:427)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$require.doInvoke(core.clj:5352)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at user$eval27.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6455)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$null_opt.invoke(main.clj:348)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:405)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve symbol: print-doc in this context
at clojure.lang.Util.runtimeException(Util.java:156)
at clojure.lang.Compiler.resolveIn(Compiler.java:6720)
at clojure.lang.Compiler.resolve(Compiler.java:6664)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6625)
at clojure.lang.Compiler.analyze(Compiler.java:6198)
... 93 more

what do u think could be the problem???..thanks!!...

PConstant/ENABLE_DEPTH_MASK does not exist

When trying the example 21_squared_noise_grid.clj, I got the error that PConstant/ENABLE_DEPTH_MASK does not exist.
That constant should exist in the 1.5.1 release of processing according to their documentation but is not in the (via lein) downloaded Jar.

Add links to processing page for each function

Each function that has processing analogous should have link to processing reference page. It should be specified in function metadata. This will be helpful when generating wiki and generally when generating docs.
In order to keep it up-to-date following tests might be added:

  • Test that checks that no function that has :processing-name metadata should have :processing-link or whatever the name of new field.
  • Test that checks that all :processing-link contains link that return status 200, not 404.

Example: load-image will have link to http://www.processing.org/reference/loadImage_.html in it metadata.

no-loop bug?

As the http://processing.org/learning/basics/noloop.html instructs us, one of the purposes of no-loop func is to provide a user with the opportunity to manually redraw a sketch, whenever it's needed. Nevertheless, it seems to happen that no-loop behaves in similar to sketch-stop way in terms of ignoring all of the outside-world events. E.g. it's not possible to (redraw) a sketch outside the (setup) func (in mouse-handler, for example).
Just a simple example to demonstrate what i'm talking about: http://pastebin.com/5mypZbZj

How to run a quil sketch?

Okay, this is a dumb one, and it clearly reveals my sense of non-lisp-aha-moment-repl-fear

But, the README and accompanying wiki page demonstrate how to run a quil sketch from a clj repl, but if a newbie user (mwah) copies and pastes the demo code into core.clj, there's no connecting path between the copy-paste-have-file to the see-pretty-stuff-in-screenshot. A one-liner of 'how to run your sketch' would be vital.

This is obviously dumb on my side and is probably better addressed with just insisting people learn clojure concepts first. But, this is a great project to learn clojure concepts by tinkering; it's just hard to find the start button.

Live reloading

Hey,

Did you test live reloading of draw() method? It would be great to be able to recompile part of application and see results immediately without restarting whole Applet Window. I'm going to start investigation by myself, but maybe you've already done it :)

thanks!
Bartek

:size has to be a literal?

This breaks with count not supported on this type: Var:

(def screen-size [640 480])
(defsketch s :size screen-size)

It works if you become a human compiler and type out the literal each time yourself:

(defsketch s :size [640 480])

If you explicitly make it a constant it works, presumably because the compiler inlines it before defsketch gets its hands on it:

(def ^:const screen-size [640 480])
(defsketch s :size screen-size)

Is there any reason to not let defsketch just take a variable though?

Can't get (start-loop) to work in event handlers

I'm trying out the following code, but (start-loop) doesn't run the sketch when clicking on it.

(ns loop-test.core                                                                                                                                                 
  (:use quil.core))

(defn setup []
  (frame-rate 2))

(defn draw []
  (println "Drawing...")
  (no-loop))

(defn mouse-released []
  (start-loop))

(defsketch loop-test
           :title "loop-test"
           :setup setup
           :draw draw
           :mouse-released mouse-released
           :size [200 200])

Question: Using processing.video with quil

Can anyone help me out with trying to get the processing.video library working with quil? I'm trying to port a processing sketch (using video library) to clojure/quil. I've gone down a few routes and have some milestones of success getting the video classes and handling processing 2.0 stuff... But I still can't get it working. I've been digging deeper and deeper into this and will try to ask here for further help.

Any suggestions welcome!

Release new version

It would be nice to release new version. 1.6.0 was released in July. Changes that were added after 1.6.0 release:

  • Added with-graphics macro.
  • Added on-close handler.
  • Added mouse wheel listener.
  • Fixed bezier-vertex function. See #40
  • Bug fix that allows to use no-loop and redraw functions. They were broken. See #45

processing 2.0

Thanks very much for creating this extremely useful wrapper/toolkit. What would it take to incorporate processing 2.0 beta rather than 1.5.1 stable? I am having difficulty understanding the clojure-jar that is in the clj file.

dependencies settings wrong

Hi ,

At first I tried to use the dependencies described in the installation section

(defproject my-art "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies org.clojure/clojure "1.3.0"]
[quil "1.2.0")

But I certainly could not install it. Instead when I try this

(defproject my-art "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.3.0"]
[quil "1.2.0"]])

I managed to install it. I wonder if its a typo mistake?

Curves appear segmented

Curves no longer seem to be smooth and 'curvy' rather they appear to be a selection of joined line segments.

How do you run mk-cheat-sheet to re-generate the cheat sheet?

There's an open issue regarding the cheat sheet using processing.core instead of quil.core. It seems like an easy fix so I'm trying to take care of it. However, I can't figure out how to run mk-cheat-sheet, which I gather generates the .tex file. If I use lein repl the docs.cheat-sheet-gen namespace is unavailable. How is cheat_sheet_gen.clj intended to be used?

Thanks for your help. Clojure newbie here, in case that wasn't obvious. Loving Quil! It's way more fun than muddling through OpenGL/C++.

:keep-on-top isn't honoured

Creating a sketch with the option :keep-on-top true doesn't create an applet that stays on top of all other windows.

Workflow

Could you describe your workflow while developing a Quil piece?

You mention interactively changing things in the fn's as you work on them, but when I try the first gen_art example, I'm having a hard time figuring out how to interactively change aspects of the rendered applet without re-instantiating the whole applet (which leaves multiple applets hanging around until I manually close them). I generally code in a Swank/Slime session in Emacs.

(arc) doesn't implement optional seventh parameter

In Processing, arcs can be drawn in three ways according to an optional third parameter:

image
image
image

The default mode is OPEN, and the other options are CHORD and PIE. Each is shown in the above examples.

These control how the arc is filled in.

Quil documentation for arc doesn't mention this optional seventh parameter, and passing a seventh parameter results in an error:

ArityException clojure.lang.ArityException: Wrong number of args (7) passed to: core$arc

This functionality would be really neat.

Keyboard input is broken

Calling (raw-key) results in

Exception in thread "Animation Thread" java.lang.IllegalArgumentException: No matching field found: _key for class quil.applet.proxy$processing.core.PApplet$IMeta$c506c738

and points to line 1954 in quil.core

Calling (key-code) results in

Exception in thread "Animation Thread" java.lang.IllegalArgumentException: No matching field found: _keyCode for class quil.applet.proxy$processing.core.PApplet$IMeta$c506c738

pointing to line 1981 in quil.core

This is the 1.6.0 release.

Quil 1.3 is not backwards-compatible with Clojure 1.3

The latest changes to make Quil 1.3 work with Clojure 1.4 mean that certain functions (like the mouse-* functions) throw errors like this:

Exception in Quil draw-fn for sketch Mouse example. : #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: _mouseX for class quil.applet.proxy$processing.core.PApplet$IMeta$c506c738>
stacktrace: java.lang.IllegalArgumentException: No matching field found: _mouseX for class quil.applet.proxy$processing.core.PApplet$IMeta$c506c738
at clojure.lang.Reflector.getInstanceField (Reflector.java:289)
clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:318)
quil.core$mouse_x.invoke (core.clj:2354)

I'm not sure if this is a known issue but it caused me to waste some time tracking it down. The example at https://github.com/quil/quil/wiki/Installing should probably be updated to latest Quil/Clojure combo too.

Wrong size after closing the window in REPL

I run applets from the REPL: run an applet (defsketch blah-blah), close it (Alt-F4), modify something, run a new (redefined) applet. After few iterations (seemingly at random, but soon), the new window has the default size (100x100).

user=> (defsketch s :title "CLOSEME" :setup (fn [] (background 128)) :draw (fn [] (let [c (random 255)] (background c))) :size [400 300])
#'user/s
user=> (defsketch s :title "CLOSEME" :setup (fn [] (background 128)) :draw (fn [] (let [c (random 255)] (background c))) :size [400 300])
#'user/s
user=> (:size (.meta s))
[400 300]
user=> s
#<PApplet$IMeta$c506c738 quil.applet.proxy$processing.core.PApplet$IMeta$c506c738[panel0,0,0,100x100,invalid,layout=java.awt.FlowLayout]>

Please note that the new applet is now 100x100 (and not 400x300 as its meta suggests).

question about dynamic workflow

working through the tutorial I successfully get to entering (use 'quil-workflow.core) into repl. This shows nil on the command line and then nothing happens - no applet opens or anything.

Is there another command that needs to be executed before the applet starts? (apologies if this is a really amature question... I've worked in processing but very new to clojure)

Tinting does not work properly using the with-graphics macro

When invoking tints with a regular image loaded using (quil/load-image), the following block of code will draw the image once first with no tint, then again at another position with a tint applied on it.

  ; inside the draw loop
  (def my-image (q/load-image "http://www.rabbit.org/adoption/bunny.jpg"))

  (q/no-tint)
  (q/image my-image 0 0)
  (q/tint 255 125)
  (q/image my-image 200 200)

However, if my-image is rendered using the with-graphics macro, the first call of quil/tint (or quil/no-tint in this case) will override all following calls to tint, which is unexpected behavior for seemingly imperative code.

  ; rendered-screen is defined using quil/make-graphics during setup
  (def screen (q/state :rendered-screen))
  (q/with-graphics screen
                   (q/background 125 75)
                   (q/rect 50 50 50 50))

  ; both renders will draw using no tint. Commenting out this line 
  ; will make both of them draw with the tint applied.
  (q/no-tint)

  (q/image screen 0 0)
  (q/tint 120 125)
  (q/image screen 200 200)

Grey circles example throws ClassCastException

after successfully using 'quil.core and feeding the REPL with the setup and draw fns, when pasting

(let [diam (random 100)           ;;Set the diameter to a value between 0 and 100
    x    (random (width))       ;;Set the x coord randomly within the sketch
    y    (random (height))]     ;;Set the y coord randomly within the sketch
(ellipse x y diam diam)))

I get: ClassCastException clojure.lang.Var$Unbound cannot be cast to processing.core.PApplet quil.core/random (core.clj:2851)

What could be causing it? I'm using Lein 2 on Ubuntu if that makes a difference.

Keep it up - Victor.

(mouse-x) bug

I have clojure 1.3.0. For quil 1.3.0 to 1.6.0 inclusive I get the following error message when calling (mouse-x) in the draw function. Quil 1.2.0 works fine.

Exception in Quil draw-fn for sketch shit : #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: _mouseX for class quil.applet.proxy$processing.core.PApplet$IMeta$c506c738>
stacktrace: java.lang.IllegalArgumentException: No matching field found: _mouseX for class quil.applet.proxy$processing.core.PApplet$IMeta$c506c738
at clojure.lang.Reflector.getInstanceField (Reflector.java:289)
clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:318)
quil.core$mouse_x.invoke (core.clj:2354)
user$draw.invoke (NO_SOURCE_FILE:1)
clojure.lang.Var.invoke (Var.java:397)
quil.applet$applet$safe_draw_fn__903.invoke (applet.clj:210)
quil.applet$applet$fn__948.invoke (applet.clj:315)
quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.draw (:-1)
processing.core.PApplet.handleDraw (:-1)
quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.handleDraw (:-1)
processing.core.PApplet.run (:-1)
quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.run (:-1)
java.lang.Thread.run (Thread.java:680)

Examples using "helpers" classes

The simple example works fine but examples/gen_art ns declarations that include quil.helpers functions won't build since the helpers classes don't get pulled down with lein deps. Perhaps update install instructions so all examples are covered?

Processing round() overflow

Stuff you don't have to worry about when using Clojure becomes an issue when interacting with Processing:
quiltest=> (round (/ 11 2))
6

quiltest=> (round (/ 11111 2))
5556

quiltest=> (round (/ 11111111111 2))
2147483647

using quil functionality outside of setup or draw

i've only started using clojure & quil, so please excuse me if this should be obvious (but i could not find any docs to that end):

using random (or stroke, and some others, i guess?) inside the definitions for setup or draw works like a charm. using them elsewhere, e.g. in another function definition or the REPL, throws an error. i notice that the example on randomness actually uses rand in a separate function.

what is going on here - is this my fault, a bug or by design?

fill with hex colors doesn't work

Passing hex colors to the fill function doesn't seem to work.
For example,
(fill (color 0 255 0)) ;; shapes fill green
(fill 0x00FF00) ;; shapes don't show against background

Maybe it is a transparency issue. I did try passing in an opaque alpha value, though, and that didn't help.

Also, hex colors work fine with background.
(background 0x00FF00) ;; makes a green background

Thanks! (And my apologies if I'm just doing something wrong in my call.)

Repl refusing input

Is there a way to rescue the REPL once it starts chucking java errors ? It seems all I can do is close it and restart.

pixels/update-pixels broken with java2d

I've been working through Nature of Code and one of the examples is displaying perlin noise by modifying the pixel array directly. I translated it to Quil but with the Java2D renderer it is only displaying a grey window, whereas it is working fine with P2D and P3D.

I tried it on both my Macbook and Windows PC. The example is working when using Processing 1.5.1 with Java2D.

https://gist.github.com/4157429

Add test snippets for all functions

Add small snippet for each function that calls that function and checks that it doesn't throw exception. Ideally snippet should show function can be used for. Snippets are used as tests.
Snippets:

  1. Color
    • Creating & Reading
    • Setting
    • Utility Macros
  2. Data
  • Conversion
  1. Debugging
    • Debugging
  2. Environment
    • Environment
  3. Image
    • Loading & Displaying
    • Pixels
    • Rendering
    • Image
  4. Input
    • Keyboard
    • Mouse
    • Time & Date
  5. Lights, Camera
    • Camera
    • Coordinates
    • Lights
    • Material Properties
  6. Math
    • Calculation
    • Random
    • Trigonometry
  7. Output
    • Files
    • Image
  8. Rendering
    • Rendering
    • Shaders
  9. Shape
    • 2D Primitives
    • 3D Primitives
    • Attributes
    • Curves
    • Loading & Displaying
    • Vertex
  10. State
    • State
  11. Structure
    • Structure
  12. Transform
    • Transform
    • Utility Macros
  13. Typography
    • Attributes
    • Loading & Displaying
    • Metrics

(width) and (height) sporadically return 100

Here's an example:

(defn foo [] (println (width) (height)))

(defn setup []
  (foo))

(defn draw [] nil)

(defsketch x
  :size [200 200]
  :title "example"
  :draw draw
  :setup setup)

About half the time I run (width) and (height) they seem to return 100
instead of the value I expect.

Quil is a very stupid name

i find it virtually impossible to narrow my search past the Twilight Saga when searching for something like quil + something-related

if you are able to do it, kudos to you, sir. but Processing was designed for non-programmers.

this is why Proce55ing was much better name than Processing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.