Awesome
clojure2d
Clojure2D is a library supporting generative coding or glitching. It's based on Java2D directly. It's Clojure only, no ClojureScript version.
Documentation
Color/Palettes/Gradients
Library contains plenty named colors, palettes and gradients.
There are various sources: colourlovers, thi.ng, paletteer, inigo quilez, cpt-city
Lists:
Examples
200+ examples are in separate repository
https://github.com/Clojure2D/clojure2d-examples
Motivation
This project is the answer to personal needs to optimize my own workflow for generative or glitch creations. I've been producing a lot of Processing code and started to suffer from limitations of working in 'write sketch and run' mode. Too much copy&paste between sketches, zillions of folders, zillions of processed images. And one day I fell in love with FP. This code is the answer.
Is it replacement for...
... quil, thi.ng, clisk, possibly other?
No, rather no. The closest is quil, which is a really great library (both Clojure and Clojurescript, great documentation and webpage, functional mode, 3d support etc.).
Clojure2d
emphasises math, color and pixel operations and adds a lot of ready to use effects/filters (see extra
namespaces`).
What's special in this library then?
In points:
- Almost decoupled display and canvas (decoupled drawing and refreshing) - you can have as many windows as you want, you can have as many canvases as you want. Display repaints selected canvas automaticaly in separate thread. This way you can operate on the canvas in your own pace.
- It is still possible to code the Processing way (e.g. you can attach a draw() function to your Display), but draw function keeps state between invocations. This allows you to avoid global state (atoms etc.) and write more functional code. The same is true for events, each Window has an assigned state which is passed through event calls.
- Easy live coding possible (Emacs/Cider/REPL)
- FastMath as main math library
- Main focus on higher level generative/glitch concepts (like sonification support, vector field functions, colorspace operations, things like slitscan etc. See my Processing sketches)
What's odd?
It's kind of a personal library which supports my (probably not optimal, not convenient for others) way of creating stuff. There are still plenty of bugs and not idiomatic code. It may be slower than Processing. Eats a lot of memory (Pixels code is generally immutable).
Installation
Add the following line as a dependency to your project.clj
Usage
Since there are still no tutorials are available, see documentation. All namespaces are described below:
clojure2d.core docs
This is the main namespace with functions in four groups:
- image file oparations (load/save); jpg, png and bmp
- canvas operations (wrapper for Java2D BufferedImage and Graphics2D)
- window and event operations (JFrame wrapper)
- session handling (logger + unique, sequential filename generator)
clojure2d.pixels docs
Pixels type as a representation of channel values of the image plus operations on pixels. Defines also:
- pixel filters (blur, erode, dilate, median, threshold, posterize, tint)
- composing Pixels
- higher order functions which operate on Pixels parallelly (filter-channels, blend-channels)
- log density renderer
clojure2d.color docs
- color space converters
- huge collection of palettes and gradients
clojure2d.color.blend docs
- collection of blending basic functions (like add, subtract, divide, difference, etc.)
clojure2d.extra
This is the namespace for common generative/glitch specific libraries:
- signal - signal processing, wave generators, effects and filters (for sonification process) docs
- overlays - postprocessing filters (like rgb/crt scanlines, etc.) docs
- segmentation - image segmentation docs
- glitch - glitching filters docs
- utils - visualize objects: palette, gradient, image, vector/scalar field... docs
- raymarching - simple ray marching 3d scene renderer (abandoned)
generateme/fastmath
All math functions are in fastmath repository.
Community
How to help
Yes! You can help with this project:
- Beginners:
- create pixel filters
- create color spaces
- Advanced:
- speed optimizations
- idiomatic clojure fixes
Discuss about it with me on Slack. Or just Pull Request.
Projects / links
- Processing glitch/generative projects
- Visual log
- Folds project
- Articles
- Facebook 1
- Facebook 2
License
Copyright © 2016-2023 GenerateMe Distributed under the MIT Licence
mixbox
is provided under the CC BY-NC 4.0 license for non-commercial use only.