|
| 1 | +# Comparison to Processing |
| 2 | + |
| 3 | +Below you can find comparison Processing functions with Clojure2d. |
| 4 | + |
| 5 | +Assuming that following variables are defined: |
| 6 | + |
| 7 | +* `window` - display created with [[show-window]] |
| 8 | +* `cnvs` - canvas created with [[canvas]] inside drawing context (see [[with-canvas->]] or [[with-canvas]]) |
| 9 | + |
| 10 | +And following namespaces are loaded: |
| 11 | + |
| 12 | +```clojure |
| 13 | +(:require [clojure2d.core :refer :all] ;; generaral Clojure2d functions |
| 14 | + [clojure2d.pixels :as p] ;; pixels operations |
| 15 | + [clojure2d.color :as c] ;; color operations |
| 16 | + [fastmath.core :as m] ;; general math functions |
| 17 | + [fastmath.random :as r]) ;; random and noise |
| 18 | +``` |
| 19 | + |
| 20 | +## Structure |
| 21 | + |
| 22 | +Processing | Clojure2d | Comments |
| 23 | +---: | --- | --- |
| 24 | +[draw()](https://processing.org/reference/draw_.html) | Any function with following signature `(fn [canvas window frame local-state] ...)` attached to window created with [[show-window]] (`:draw-fn` key). | Such function is called before refresh of the display. Result is passed as `local-state` in the next call. |
| 25 | +[exit()](https://processing.org/reference/exit_.html) | [[close-window]] | Closes window programmatically. |
| 26 | +[loop()](https://processing.org/reference/loop_.html) | not implemented | possible in future versions |
| 27 | +[noLoop()](https://processing.org/reference/noLoop_.html) | not implemented | possible in future versions |
| 28 | +[popStyle()](https://processing.org/reference/popStyle_.html) | not implemented | |
| 29 | +[pushStyle()](https://processing.org/reference/pushStyle_.html) | not implemented | |
| 30 | +[redraw()](https://processing.org/reference/redraw_.html) | not implemented | not necessary |
| 31 | +[setup()](https://processing.org/reference/setup_.html) | Any function with following signature `(fn [canvas window] ...)` attached to window created with [[show-window]] (`:setup` key). | Returned value is treated as local-state for first call of drawing function. |
| 32 | +[thread()](https://processing.org/reference/thread_.html) | | use `future` |
| 33 | +all the rest | use Clojure | |
| 34 | + |
| 35 | +## Environment |
| 36 | + |
| 37 | +Processing | Clojure2d | Comments |
| 38 | +---: | --- | --- |
| 39 | +[cursor()](https://processing.org/reference/cursor_.html) | not implemented | possible in future versions |
| 40 | +[delay()](https://processing.org/reference/delay_.html) | not implemented | use `Thread/sleep` |
| 41 | +[displayDensity()](https://processing.org/reference/displayDensity_.html) | not implemented | |
| 42 | +[focused](https://processing.org/reference/focused.html) | not implemented | possible in future versions |
| 43 | +[frameCount](https://processing.org/reference/frameCount.html) | implemented | frame number is passed to the drawing function as third parameter | |
| 44 | +[frameRate()](https://processing.org/reference/frameRate_.html) | implemented | set `:fps` key when [[show-window]] is called |
| 45 | +[frameRate](https://processing.org/reference/frameRate.html) | not implemented | |
| 46 | +[fullScreen()](https://processing.org/reference/fullScreen_.html) | not implemented | possible in future versions |
| 47 | +[height](https://processing.org/reference/height.html) | [[height]] | it's a function working on canvas/window/image |
| 48 | +[noCursor()](https://processing.org/reference/noCursor_.html) | not implemented | possible in future versions |
| 49 | +[noSmooth()](https://processing.org/reference/noSmooth_.html) | implemented | use `:low` quality key in [[canvas]] call |
| 50 | +[pixelDensity()](https://processing.org/reference/pixelDensity_.html) | not implemented | for Retina use two times bigger canvas/window and call `(scale canvas 2)`. |
| 51 | +[pixelHeight](https://processing.org/reference/pixelHeight.html) | not implemented | |
| 52 | +[pixelWidth](https://processing.org/reference/pixelWidth.html) | not implemented | |
| 53 | +[settings()](https://processing.org/reference/settings_.html) | not necessary | |
| 54 | +[size()](https://processing.org/reference/size_.html) | implemented | set size in [[canvas]] or [[show-window]] calls |
| 55 | +[smooth()](https://processing.org/reference/smooth_.html) | implemented | use one of the keys defined in [[rendering-hints]] and pass to [[canvas]] or [[show-window]] |
| 56 | +[width](https://processing.org/reference/width.html) | [[width]] | it's a function working on canvas/window/image |
| 57 | + |
| 58 | +## Data |
| 59 | + |
| 60 | +Use Clojure2d data types and functions |
| 61 | + |
| 62 | +## Control |
| 63 | + |
| 64 | +Use Clojure2d functions |
| 65 | + |
0 commit comments