├── .gitignore ├── LICENSE ├── README.md ├── abstract_noise.jpg ├── abstract_noise2.jpg ├── abstract_noise3.jpg ├── abstract_noise4.jpg ├── blue_drops.jpg ├── ice-cristals.jpg ├── noisey_tris.jpg ├── output.jpg ├── project.clj ├── rivers_and_hills.jpg ├── rivers_and_hills_scale.jpg ├── shuffled_grad_noise.jpg ├── shuffled_grad_palette.jpg ├── shuffled_grad_palette_scale_1.jpg ├── shuffled_grad_palette_scale_2.jpg ├── snakeskin.jpg ├── snakeskin_big.jpg ├── snakeskin_big_crop.jpg ├── squares.jpg ├── src └── staticart │ ├── color.clj │ ├── color_matrix.clj │ ├── core.clj │ ├── distortion.clj │ ├── draw.clj │ ├── generic_helper.clj │ ├── geometry_helper.clj │ ├── matrix.clj │ ├── noise.clj │ ├── random_helper.clj │ ├── screen_locations.clj │ ├── settings.clj │ ├── sketch_1.clj │ ├── sketch_2.clj │ ├── sketch_3.clj │ ├── sketch_4.clj │ ├── sketch_5.clj │ ├── sketch_6.clj │ ├── sketch_7.clj │ ├── sketch_8.clj │ ├── sketch_9.clj │ └── subdivision.clj ├── turb_noise_1.jpg ├── turb_noise_2.jpg ├── turb_noise_3_big.jpg ├── turb_tris.jpg ├── turb_tris_2.jpg └── turb_tris_3.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of Washington and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # staticart 2 | 3 | My static generative art with clojure, quil and thi.ng 4 | -------------------------------------------------------------------------------- /abstract_noise.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/abstract_noise.jpg -------------------------------------------------------------------------------- /abstract_noise2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/abstract_noise2.jpg -------------------------------------------------------------------------------- /abstract_noise3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/abstract_noise3.jpg -------------------------------------------------------------------------------- /abstract_noise4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/abstract_noise4.jpg -------------------------------------------------------------------------------- /blue_drops.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/blue_drops.jpg -------------------------------------------------------------------------------- /ice-cristals.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/ice-cristals.jpg -------------------------------------------------------------------------------- /noisey_tris.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/noisey_tris.jpg -------------------------------------------------------------------------------- /output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/output.jpg -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject staticart "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.9.0"] 7 | [thi.ng/math "0.2.2-SNAPSHOT"] 8 | [thi.ng/geom "0.0.1178-SNAPSHOT"] 9 | [thi.ng/color "1.3.0"] 10 | [org.clojure/tools.trace "0.7.10"] 11 | [quil "2.7.1"]]) 12 | -------------------------------------------------------------------------------- /rivers_and_hills.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/rivers_and_hills.jpg -------------------------------------------------------------------------------- /rivers_and_hills_scale.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/rivers_and_hills_scale.jpg -------------------------------------------------------------------------------- /shuffled_grad_noise.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/shuffled_grad_noise.jpg -------------------------------------------------------------------------------- /shuffled_grad_palette.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/shuffled_grad_palette.jpg -------------------------------------------------------------------------------- /shuffled_grad_palette_scale_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/shuffled_grad_palette_scale_1.jpg -------------------------------------------------------------------------------- /shuffled_grad_palette_scale_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/shuffled_grad_palette_scale_2.jpg -------------------------------------------------------------------------------- /snakeskin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/snakeskin.jpg -------------------------------------------------------------------------------- /snakeskin_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/snakeskin_big.jpg -------------------------------------------------------------------------------- /snakeskin_big_crop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/snakeskin_big_crop.jpg -------------------------------------------------------------------------------- /squares.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/squares.jpg -------------------------------------------------------------------------------- /src/staticart/color.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.color 2 | (:require [thi.ng.color.core :as c] 3 | [thi.ng.color.gradients :as grad])) 4 | 5 | (def palette-ice 6 | [[178 96 75] 7 | [178 70 80] 8 | [179 52 85] 9 | [184 35 94] 10 | [174 23 100]]) 11 | 12 | (def palette-ice2 13 | [[197 96 55] 14 | [187 99 56] 15 | [174 100 66] 16 | [167 99 76] 17 | [63 42 85]]) 18 | 19 | (def palette-soft1 20 | [[90 2 32] 21 | [1 62 95] 22 | [48 60 100] 23 | [198 78 63] 24 | [170 42 76] 25 | ]) 26 | 27 | (def palette-dark-red 28 | [[15 97 13] 29 | [10 92 38] 30 | [7 92 58] 31 | [16 96 74] 32 | [39 89 96] 33 | ]) 34 | 35 | (defn pick-color [palette alpha] (conj (rand-nth palette) alpha)) 36 | 37 | (defn color-stream [palette alpha] (cycle (map #(conj % alpha) palette))) 38 | (defn random-color-stream [palette alpha] (repeatedly #(conj (rand-nth palette) alpha))) 39 | 40 | (def palette_1 [(c/as-rgba (c/css "rgba(51,92,103,1)")) 41 | (c/as-rgba (c/css "rgba(255,243,176,1)")) 42 | (c/as-rgba (c/css "rgba(224,159,62,1)")) 43 | (c/as-rgba (c/css "rgba(158,42,43,1)")) 44 | (c/as-rgba (c/css "rgba(84,11,14,1)"))]) 45 | 46 | (def palette_2 [(c/as-rgba (c/css "rgba(91,192,235,1)")) 47 | (c/as-rgba (c/css "rgba(253,231,76,1)")) 48 | (c/as-rgba (c/css "rgba(155,197,61,1)")) 49 | (c/as-rgba (c/css "rgba(229,89,52,1)")) 50 | (c/as-rgba (c/css "rgba(250,121,33,1)"))]) 51 | 52 | (def palette_3 [(c/as-rgba (c/css "rgba(60,21,24,1)")) 53 | (c/as-rgba (c/css "rgba(105,20,14,1)")) 54 | (c/as-rgba (c/css "rgba(164,66,0,1)")) 55 | (c/as-rgba (c/css "rgba(213,137,54,1)")) 56 | (c/as-rgba (c/css "rgba(242,243,174,1)"))]) 57 | 58 | (def palette_4 [(c/as-rgba (c/css "rgba(27,153,139,1)")) 59 | (c/as-rgba (c/css "rgba(45,48,71,1)")) 60 | (c/as-rgba (c/css "rgba(255,253,130,1)")) 61 | (c/as-rgba (c/css "rgba(255,155,113,1)")) 62 | (c/as-rgba (c/css "rgba(232,72,85,1)"))]) 63 | 64 | (def palette_5 [(c/as-rgba (c/css "rgba(51,92,103,1)")) 65 | (c/as-rgba (c/css "rgba(255,243,176,1)")) 66 | (c/as-rgba (c/css "rgba(224,159,62,1)")) 67 | (c/as-rgba (c/css "rgba(158,42,43,1)")) 68 | (c/as-rgba (c/css "rgba(84,11,14,1)"))]) 69 | 70 | (def palette_6 [(c/as-rgba (c/css "rgba(237,106,90,1)")) 71 | (c/as-rgba (c/css "rgba(244,241,187,1)")) 72 | (c/as-rgba (c/css "rgba(155,193,188,1)")) 73 | (c/as-rgba (c/css "rgba(92,164,169,1)")) 74 | (c/as-rgba (c/css "rgba(230,235,224,1)"))]) 75 | 76 | (defn pick2 [palette] 77 | (let [c1 (rand-nth palette) 78 | c2 (rand-nth palette)] 79 | (if (not= c1 c2) [c1 c2] (recur palette)))) 80 | 81 | (defn random-grad [palette steps] 82 | (let [[c1 c2] (pick2 palette)] 83 | (grad/cosine-gradient 84 | steps 85 | (grad/cosine-coefficients c1 c2)))) 86 | 87 | (defn shuffled-random-grad [palette steps] (shuffle (random-grad palette steps))) 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /src/staticart/color_matrix.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.color-matrix 2 | (:require [quil.core :as q :include-macros true] 3 | [staticart.settings :refer [settings]] 4 | [thi.ng.color.core :as c])) 5 | 6 | (set! *warn-on-reflection* false) ;; To avoid accidental reflection 7 | 8 | (defn make-color-matrix [width height] 9 | ^"[[Lthi.ng.color.core.RGBA;" (make-array (Class/forName "thi.ng.color.core.RGBA") height width)) 10 | 11 | (def ^"[[Lthi.ng.color.core.RGBA;" cmatrix (make-color-matrix (:width settings) (:height settings))) 12 | 13 | (defmacro aget2c [a x y] 14 | `(aget ^"[Lthi.ng.color.core.RGBA;" (aget ~a ~y) ~x)) 15 | 16 | (defmacro aset2c [a x y v] 17 | `(aset ^"[Lthi.ng.color.core.RGBA;" (aget ~a ~y) ~x ~v)) 18 | 19 | (defn on-points [points f] 20 | (time (doseq [[x y] points] 21 | (when (and 22 | (< x (alength (aget cmatrix 0))) 23 | (> x 0) 24 | (< y (alength cmatrix)) 25 | (> y 0)) 26 | (f cmatrix x y))))) 27 | 28 | (defn on-matrix [f] 29 | (let [ps (for [x (range (alength ^"[Lthi.ng.color.core.RGBA;" (aget cmatrix 0))) 30 | y (range (alength cmatrix))] [x y])] 31 | (on-points ps f))) 32 | 33 | (defn set-function [coloring-function] 34 | (fn [^"[[Lthi.ng.color.core.RGBA;" mt x y] 35 | (aset2c mt x y (coloring-function x y)))) 36 | 37 | (defn coloring-on-matrix [coloring-function] 38 | (on-matrix (set-function coloring-function))) 39 | 40 | (defn reset-matrix [color] 41 | (coloring-on-matrix (fn [x y] color))) 42 | 43 | (defn draw-matrix [] 44 | (on-matrix (fn [^"[[Lthi.ng.color.core.RGBA;" m x y] 45 | (q/set-pixel x y (apply q/color (deref (aget2c m x y))))))) 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/staticart/core.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.core 2 | (:require [quil.core :as q] 3 | [quil.middleware :as mid] 4 | [staticart.settings :refer [settings]] 5 | [staticart.sketch-9 :as sketch])) 6 | 7 | (defn setup [] 8 | (q/no-loop) 9 | (q/smooth) 10 | (q/color-mode :rgb 1.0 1.0 1.0 1.0)) 11 | 12 | (q/defsketch staticart 13 | :title "My Quil Sketch" 14 | :features [:no-bind-output] 15 | :size [(:width settings) (:height settings)] 16 | :setup setup 17 | :draw sketch/draw 18 | :features [:keep-on-top] 19 | :middleware [mid/pause-on-error] 20 | ) 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/staticart/distortion.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.distortion 2 | (:require [staticart.geometry-helper :refer :all] 3 | [staticart.random-helper :as rh])) 4 | 5 | (defn distort-line [p1 p2 points variation] 6 | (let [inner-points (rest (butlast (points-on-line p1 p2 (+ 2 points)))) 7 | dist-points (rh/gauss-variate-points inner-points variation) 8 | with-head-tail (concat [p1] dist-points [p2])] 9 | (println inner-points) 10 | (println dist-points) 11 | with-head-tail)) 12 | -------------------------------------------------------------------------------- /src/staticart/draw.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.draw 2 | (:require [quil.core :as q :include-macros true])) 3 | 4 | (def background q/background) 5 | (def fill q/fill) 6 | (def no-fill q/no-fill) 7 | (def stroke q/stroke) 8 | (def stroke-weight q/stroke-weight) 9 | (def no-stroke q/no-stroke) 10 | (def save q/save) 11 | 12 | (defn point [p] 13 | (q/point (nth p 0) (nth p 1))) 14 | 15 | (defn line [p1 p2] 16 | (q/line (nth p1 0) (nth p1 1) (nth p2 0) (nth p2 1))) 17 | 18 | (defn vertex [ps & closed] 19 | (q/begin-shape) 20 | (doseq [p ps] (apply q/vertex p)) 21 | (when closed (apply q/vertex (first ps))) 22 | (q/end-shape)) 23 | 24 | (defn curve-through-points [ps & closed] 25 | (q/begin-shape) 26 | (apply q/curve-vertex (first ps)) 27 | (doseq [p ps] (apply q/curve-vertex p)) 28 | (if closed 29 | (do 30 | (apply q/curve-vertex (first ps)) 31 | (apply q/curve-vertex (second ps))) 32 | (apply q/curve-vertex (last ps))) 33 | (q/end-shape)) 34 | 35 | (defn debug-point [p] 36 | (q/ellipse (nth p 0) (nth p 1) 5 5)) 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/staticart/generic_helper.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.generic-helper 2 | (:require [thi.ng.math.core :as m])) 3 | 4 | (defn pth [coll fact low high] 5 | (nth coll (int (m/map-interval-clamped fact low high 0 (- (count coll) 1))))) 6 | -------------------------------------------------------------------------------- /src/staticart/geometry_helper.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.geometry-helper 2 | (:require [thi.ng.math.core :as m])) 3 | 4 | (defn points-on-line [p1 p2 n] (map #(m/mix p1 p2 %) (range 0 1.00001 (/ 1 (- n 1))))) 5 | -------------------------------------------------------------------------------- /src/staticart/matrix.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.matrix 2 | (:require [quil.core :as q :include-macros true] 3 | [staticart.settings :refer [settings]])) 4 | 5 | #_(set! *warn-on-reflection* false) ;; To avoid accidental reflection 6 | 7 | (defn make-int-matrix [width height] 8 | ^"[[I" (make-array Integer/TYPE height width)) 9 | 10 | (def ^"[[I" matrix (make-int-matrix (:width settings) (:height settings))) 11 | 12 | (defmacro aget2i [a x y] 13 | `(aget ^"[I" (aget ~a ~y) ~x)) 14 | 15 | (defmacro aset2i [a x y v] 16 | `(aset ^"[I" (aget ~a ~y) ~x ~v)) 17 | 18 | (defn on-points [points f] 19 | (time (doseq [[x y] points] (f matrix x y)))) 20 | 21 | (defn on-matrix [f] 22 | (let [ps (for [x (range (alength ^"[I" (aget matrix 0))) 23 | y (range (alength matrix))] [x y])] 24 | (on-points ps f))) 25 | 26 | (defn draw-matrix [] 27 | (on-matrix (fn [^"[[I" m x y] (q/set-pixel x y (aget2i m x y))))) 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/staticart/noise.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.noise 2 | (:require [quil.core :as q :include-macros true] 3 | [staticart.settings :refer [settings]] 4 | [thi.ng.math.noise :as noise])) 5 | 6 | (def octave-pow2 [1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0]) 7 | 8 | (defn noise-in-octave 9 | [x y s o] 10 | (let [o (nth octave-pow2 o) 11 | s (* s o)] 12 | (/ (noise/noise2 (* x s) (* y s)) o))) 13 | 14 | (defn octave-noise2 15 | [x y s o] 16 | (loop [n 0.0, o o] 17 | (if (>= o 0) 18 | (recur (+ n (noise-in-octave x y s o)) (dec o)) 19 | n))) 20 | 21 | #_(defn noise-image 22 | [octaves scale] 23 | (let [r (rand-int 500)] 24 | (doseq [y (range (:height settings)) 25 | x (range (:width settings)) 26 | :let [n (octave-noise2 (+ r x) (+ r y) scale octaves) 27 | n (+ (* n 20) 60)]] 28 | (q/set-pixel x y (q/color 50 100 n 1))))) 29 | 30 | (defn noise-image 31 | [ps color octaves scale] 32 | (let [r (rand-int 500)] 33 | (doseq [p ps 34 | :let [m (octave-noise2 (+ r (first p)) (+ r (last p)) scale octaves) 35 | n (+ (nth color 2) (* m 20))]] 36 | (q/set-pixel (first p) (last p) (q/color (nth color 0) (nth color 1) n 1))))) 37 | 38 | (defn noise-image-turb 39 | [octaves scale turbulence] 40 | (let [r (rand-int 500)] 41 | (doseq [y (range (:height settings)) 42 | x (range (:width settings)) 43 | :let [x' (+ x r (turbulence x y)) 44 | y' (+ y r (turbulence y x)) 45 | n (octave-noise2 x' y' scale octaves) 46 | n (+ (* n 30) 40) 47 | m (octave-noise2 (+ x r) (+ y r) 0.02 octaves) 48 | m (+ (* m 15) 70)]] 49 | (q/set-pixel x y (q/color n 90 m 1))))) 50 | 51 | 52 | (comment 53 | 54 | (time (noise-image-gray 300 6 0.01)) 55 | ) 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/staticart/random_helper.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.random-helper 2 | (:require [thi.ng.geom.vector :as v :refer [vec2]]) 3 | (:import [java.util Random])) 4 | 5 | (def jrand (Random.)) 6 | 7 | (defn gauss [mean variance] 8 | (+ mean (* variance (.nextGaussian jrand)))) 9 | 10 | (defn gauss-variate [p variance] 11 | (vec2 (gauss (:x p) variance) (gauss (:y p) variance))) 12 | 13 | (defn gauss-variate-points [ps variance] 14 | (map #(gauss-variate % variance) ps)) 15 | -------------------------------------------------------------------------------- /src/staticart/screen_locations.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.screen-locations 2 | (:require [staticart.settings :refer [settings]] 3 | [thi.ng.geom.core :as g] 4 | [thi.ng.geom.vector :as v :refer [vec2]] 5 | [thi.ng.math.core :as m])) 6 | 7 | (defn h 8 | ([] (h 1.0)) 9 | ([value] (* (:height settings) value))) 10 | 11 | (defn w 12 | ([] (w 1.0)) 13 | ([value] (* (:width settings) value))) 14 | 15 | (defn mid-point [] (vec2 (w 0.5) (h 0.5))) 16 | 17 | (defn point-on-screen [ww hh] (vec2 (w ww) (h hh))) 18 | 19 | (def pos point-on-screen) 20 | 21 | (def screen-point (vec2 (:width settings) (:height settings))) 22 | 23 | (def screen-mid-point (vec2 (/ (:width settings) 2) (/ (:height settings) 2))) 24 | 25 | (defn scale-to-screen [p] 26 | (m/* p screen-point)) 27 | 28 | (defn scale-to-mid-screen [p] 29 | (m/* p screen-mid-point)) 30 | 31 | (def all-points (for [x (range (:width settings)) 32 | y (range (:height settings))] 33 | (vec2 x y))) 34 | -------------------------------------------------------------------------------- /src/staticart/settings.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.settings) 2 | 3 | (def settings 4 | {:width 2000 5 | :height 2000}) 6 | -------------------------------------------------------------------------------- /src/staticart/sketch_1.clj: -------------------------------------------------------------------------------- 1 | 2 | (ns staticart.sketch-1 3 | (:require [staticart.color :as col] 4 | [staticart.distortion :as dist] 5 | [staticart.draw :as d] 6 | [staticart.geometry-helper :refer :all] 7 | [staticart.random-helper :as rh] 8 | [staticart.screen-locations :refer :all] 9 | [staticart.subdivision :as sub])) 10 | 11 | (defn draw [] 12 | (d/background 360) 13 | (d/no-stroke) 14 | (let [tris [[(pos 0 0) (pos 1 0) (pos 1 1)] 15 | [(pos 0 0) (pos 0 1) (pos 1 1)]] 16 | subtris (sub/rec-divide-tris tris 5) 17 | subsubtris (for [t subtris] 18 | (let [divided (sub/rec-divide-tris [t] 5)] 19 | (for [n (range (* 2 (count divided)))] (rand-nth divided))))] 20 | (doseq [randtris subsubtris] 21 | (apply d/fill (col/pick-color col/palette-soft1 0.2)) 22 | (doseq [t randtris] 23 | (d/vertex t true)))) 24 | (d/save "output.jpg")) 25 | 26 | -------------------------------------------------------------------------------- /src/staticart/sketch_2.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.sketch-2 2 | (:require [quil.core :as q :include-macros true] 3 | [staticart.draw :as d] 4 | [staticart.noise :as noise] 5 | [staticart.settings :refer [settings]])) 6 | 7 | (defn draw [] 8 | (d/background 360) 9 | (d/stroke 0) 10 | #_(noise/noise-image 6 0.01) 11 | (noise/noise-image-turb 6 0.01 #(* 420 (* (Math/sin (* % 0.01)) (Math/sin (* %2 0.01))))) 12 | (d/save "output.jpg")) 13 | 14 | -------------------------------------------------------------------------------- /src/staticart/sketch_3.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.sketch-3 2 | (:require [clojure.tools.trace :refer :all] 3 | [quil.core :as q :include-macros true] 4 | [staticart.color :as c] 5 | [staticart.draw :as d] 6 | [staticart.noise :as noise] 7 | [staticart.subdivision :as sub] 8 | [thi.ng.geom.core :as g] 9 | [thi.ng.geom.matrix :refer [M32]] 10 | [thi.ng.geom.triangle :as tri] 11 | [thi.ng.geom.utils :as gu] 12 | [thi.ng.geom.utils.delaunay :as del] 13 | [thi.ng.geom.vector :as v :refer [vec2]] 14 | [thi.ng.math.core :as m] 15 | [thi.ng.math.macros :as mm])) 16 | 17 | (defn draw-matrix [matrix] 18 | (doseq [x (range (count (aget matrix 0))) y (range (count matrix))] 19 | (q/set-pixel x y (aget matrix x y)))) 20 | 21 | 22 | 23 | (defn spiral 24 | [center start end r1 r2 steps] 25 | (map 26 | (fn [r theta] (m/+ (g/as-cartesian (vec2 r theta)) center)) 27 | (range r1 r2 (mm/subdiv r2 r1 steps)) 28 | (range start end (mm/subdiv end start steps)))) 29 | 30 | (defn points-in-triangle [triangle] 31 | (let [tri (tri/triangle2 triangle) 32 | b (g/bounds tri) 33 | x-start (:x (:p b)) 34 | y-start (:y (:p b)) 35 | x-end (+ x-start (:x (:size b))) 36 | y-end (+ y-start (:y (:size b))) 37 | xs (range x-start x-end) 38 | ys (range y-start y-end) 39 | ps (for [x xs y ys] [x y])] 40 | (filter #(g/contains-point? tri %) ps))) 41 | 42 | (defn draw [] 43 | (d/background 360) 44 | (d/stroke 0) 45 | (d/no-fill) 46 | (let [full [(vec2 0 0) (vec2 500 0) (vec2 500 500) (vec2 0 500)] 47 | tris (sub/rec-divide-tris (gu/tessellate-with-point full) 3) 48 | trips (map points-in-triangle tris)] 49 | (time (doseq [ps trips] 50 | (noise/noise-image ps (c/pick-color c/palette-dark-red 1) 6 0.01))) 51 | (doseq [t tris] (d/vertex t true)) 52 | #_(time (doseq [p ps] (q/set-pixel (first p) (last p) (q/color (rand-int 360)))))) 53 | (d/save "output.jpg")) 54 | 55 | -------------------------------------------------------------------------------- /src/staticart/sketch_4.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.sketch-4 2 | (:require [clojure.tools.trace :refer :all] 3 | [quil.core :as q :include-macros true] 4 | [staticart.color :as c] 5 | [staticart.draw :as d] 6 | [staticart.noise :as noise] 7 | [staticart.settings :refer [settings]] 8 | [staticart.subdivision :as sub] 9 | [thi.ng.geom.core :as g] 10 | [thi.ng.geom.matrix :refer [M32]] 11 | [thi.ng.geom.triangle :as tri] 12 | [thi.ng.geom.utils :as gu] 13 | [thi.ng.geom.utils.delaunay :as del] 14 | [thi.ng.geom.vector :as v :refer [vec2]] 15 | [thi.ng.math.core :as m] 16 | [thi.ng.math.macros :as mm])) 17 | 18 | #_(set! *warn-on-reflection* false) ;; To avoid accidental reflection 19 | 20 | (defn make-int-matrix [width height] 21 | ^"[[I" (make-array Integer/TYPE height width)) 22 | 23 | (def ^"[[I" matrix (make-int-matrix (:width settings) (:height settings))) 24 | 25 | (defmacro aget2i [a x y] 26 | `(aget ^"[I" (aget ~a ~y) ~x)) 27 | 28 | (defmacro aset2i [a x y v] 29 | `(aset ^"[I" (aget ~a ~y) ~x ~v)) 30 | 31 | (defn on-points [points f] 32 | (time (doseq [[x y] points] (f matrix x y)))) 33 | 34 | (defn on-matrix [f] 35 | (let [ps (for [x (range (alength ^"[I" (aget matrix 0))) 36 | y (range (alength matrix))] [x y])] 37 | (on-points ps f))) 38 | 39 | (defn draw-matrix [] 40 | (on-matrix (fn [^"[[I" m x y] (q/set-pixel x y (aget2i m x y))))) 41 | 42 | (defn points-in-triangle [triangle] 43 | (let [tri (tri/triangle2 triangle) 44 | b (g/bounds tri) 45 | x-start (:x (:p b)) 46 | y-start (:y (:p b)) 47 | x-end (+ x-start (:x (:size b))) 48 | y-end (+ y-start (:y (:size b))) 49 | xs (range x-start x-end) 50 | ys (range y-start y-end) 51 | ps (for [x xs y ys] [x y])] 52 | (filter #(g/contains-point? tri %) ps))) 53 | 54 | (defn noise-function [color octaves scale turbulence] 55 | (let [r 3] 56 | (fn [^"[[I" m x y] 57 | (let [x' (+ x r (turbulence x y)) 58 | y' (+ y r (turbulence y x)) 59 | n (noise/octave-noise2 x' y' scale octaves) 60 | newb (+ (nth color 2) (* n 20)) 61 | newh (- (nth color 0) (* n 20))] 62 | (aset2i m x y ^int (q/color (nth color 0) (nth color 1) newb 1)))))) 63 | 64 | 65 | (defn draw [] 66 | (d/background 0 0 0 0) 67 | 68 | #_(on-matrix (noise-function [7 92 58] 6 0.001)) 69 | 70 | #_(let [ps (points-in-triangle [(vec2 200 50) (vec2 400 400) (vec2 50 400)])] 71 | (on-points ps (noise-function (c/pick-color c/palette-dark-red 1) 6 0.01))) 72 | 73 | (let [full [(vec2 0 0) (vec2 500 0) (vec2 500 500) (vec2 0 500)] 74 | tris (sub/rec-divide-tris (gu/tessellate-with-point full) 2) 75 | trips (map points-in-triangle tris)] 76 | (doseq [ps trips] 77 | (on-points ps (noise-function (c/pick-color c/palette-dark-red 1) 6 0.006 #(* 420 (* (Math/sin (* % 0.1)) (Math/sin (* %2 0.1))))))) 78 | (draw-matrix) 79 | #_(doseq [t tris] (d/vertex t true))) 80 | 81 | (d/save "output.jpg")) 82 | 83 | 84 | ;(noise/noise-image-turb 6 0.01 #(* 420 (* (Math/sin (* % 0.01)) (Math/sin (* %2 0.01))))) 85 | -------------------------------------------------------------------------------- /src/staticart/sketch_5.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.sketch-5 2 | (:require [clojure.tools.trace :refer :all] 3 | [quil.core :as q :include-macros true] 4 | [staticart.color :as c] 5 | [staticart.draw :as d] 6 | [staticart.matrix :as mt] 7 | [staticart.noise :as noise] 8 | [staticart.settings :refer [settings]] 9 | [staticart.subdivision :as sub] 10 | [thi.ng.geom.core :as g] 11 | [thi.ng.geom.matrix :refer [M32]] 12 | [thi.ng.geom.triangle :as tri] 13 | [thi.ng.geom.utils :as gu] 14 | [thi.ng.geom.utils.delaunay :as del] 15 | [thi.ng.geom.vector :as v :refer [vec2]] 16 | [thi.ng.math.core :as m] 17 | [thi.ng.math.macros :as mm])) 18 | 19 | (defn noise-function [color octaves scale turbulence] 20 | (let [r 3] 21 | (fn [^"[[I" m x y] 22 | (let [x' (+ x r (turbulence x y)) 23 | y' (+ y r (turbulence y x)) 24 | n (noise/octave-noise2 x' y' scale octaves) 25 | newb (+ (nth color 2) (* n 20)) 26 | newh (- (nth color 0) (* n 20))] 27 | (mt/aset2i m x y ^int (q/color (nth color 0) (nth color 1) newb 1)))))) 28 | 29 | 30 | (defn draw [] 31 | (d/background 0 0 0 0) 32 | 33 | (let [l (/ 500 10) 34 | starts (for [x (range 0 500 l) y (range 0 500 l)] [x y]) 35 | blocks (map #(for [x (range (nth % 0) (+ (nth % 0) l)) y (range (nth % 1) (+ (nth % 1) l))] [x y]) starts)] 36 | (doseq [ps blocks] 37 | (mt/on-points ps (noise-function 38 | (c/pick-color c/palette-dark-red 1) 6 0.006 39 | #(* 420 (* (Math/sin (* % (/ Math/PI 25))) (Math/sin (* %2 (/ Math/PI 25)))))))) 40 | (mt/draw-matrix) 41 | #_(doseq [t tris] (d/vertex t true))) 42 | 43 | (d/save "output.jpg")) 44 | 45 | -------------------------------------------------------------------------------- /src/staticart/sketch_6.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.sketch-6 2 | (:require [clojure.tools.trace :refer :all] 3 | [quil.core :as q :include-macros true] 4 | [staticart.color :as c] 5 | [staticart.draw :as d] 6 | [staticart.matrix :as mt] 7 | [staticart.noise :as noise] 8 | [staticart.settings :refer [settings]] 9 | [staticart.subdivision :as sub] 10 | [thi.ng.geom.core :as g] 11 | [thi.ng.geom.matrix :refer [M32]] 12 | [thi.ng.geom.triangle :as tri] 13 | [thi.ng.geom.utils :as gu] 14 | [thi.ng.geom.utils.delaunay :as del] 15 | [thi.ng.geom.vector :as v :refer [vec2]] 16 | [thi.ng.math.core :as m] 17 | [thi.ng.math.macros :as mm])) 18 | 19 | (defn noise-function [color octaves scale turbh turbb] 20 | (let [r 3] 21 | (fn [^"[[I" m x y] 22 | (let [[xh yh] (turbh x y) 23 | h (noise/octave-noise2 xh yh scale octaves) 24 | newh (+ 12 (- (nth color 0) (* h 25))) 25 | [xb yb] (turbb x y) 26 | b (noise/octave-noise2 xb yb scale octaves) 27 | newb (+ (nth color 2) (* b 50))] 28 | (mt/aset2i m x y ^int (q/color newh (nth color 1) newb 1)))))) 29 | 30 | (defn attractor [x y a1 a2 a3 a4 a5 a6] 31 | (+ a1 (* a2 x) (* a3 x x) (* a4 x y) (* a5 y) (* a6 y y))) 32 | 33 | (defn cosattractor [x y a b c d] 34 | [(+ (Math/cos (* y b)) (* c (Math/sin (* x b)))) 35 | (+ (Math/cos (* x a)) (* d (Math/sin (* y a))))]) 36 | 37 | (defn draw [] 38 | (d/background 0 0 0 0) 39 | 40 | (mt/on-matrix (noise-function 41 | (conj (nth c/palette-dark-red 3) 1) 3 0.01 42 | #(map (partial * 150) (cosattractor % %2 0.008 0.25 1 1)) 43 | #(map (partial * 100) (cosattractor % %2 0.004 0.12 -1 0.7)))) 44 | 45 | #_(* 80 (noise/octave-noise2 % %2 0.01 6)) 46 | #_(* 80 (* (Math/sin (* % (/ Math/PI 100))) 47 | (Math/sin (* %2 (/ Math/PI 200))))) 48 | 49 | (mt/draw-matrix) 50 | 51 | (d/save "output.jpg")) 52 | 53 | -------------------------------------------------------------------------------- /src/staticart/sketch_7.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.sketch-7 2 | (:require [clojure.tools.trace :refer :all] 3 | [quil.core :as q :include-macros true] 4 | [staticart.color-matrix :as cm] 5 | [staticart.draw :as d] 6 | [staticart.noise :as noise] 7 | [staticart.settings :refer [settings]] 8 | [staticart.subdivision :as sub] 9 | [thi.ng.color.core :as c] 10 | [thi.ng.color.gradients :as grad] 11 | [thi.ng.geom.core :as g] 12 | [thi.ng.geom.matrix :refer [M32]] 13 | [thi.ng.geom.triangle :as tri] 14 | [thi.ng.geom.utils :as gu] 15 | [thi.ng.geom.utils.delaunay :as del] 16 | [thi.ng.geom.vector :as v :refer [vec2]] 17 | [thi.ng.math.core :as m] 18 | [thi.ng.math.macros :as mm])) 19 | 20 | (def colors [(c/as-rgba (c/css "rgba(237,106,90,1)")) 21 | (c/as-rgba (c/css "rgba(244,241,187,1)")) 22 | (c/as-rgba (c/css "rgba(155,193,188,1)")) 23 | (c/as-rgba (c/css "rgba(92,164,169,1)")) 24 | (c/as-rgba (c/css "rgba(230,235,224,1)"))]) 25 | 26 | (def grad1 (shuffle (grad/cosine-gradient 27 | 50 (grad/cosine-coefficients (nth colors 0) (nth colors 1))))) 28 | 29 | (def grad2 (grad/cosine-gradient 30 | 50 (grad/cosine-coefficients (nth colors 1) (nth colors 2)))) 31 | 32 | (def grad3 (shuffle (grad/cosine-gradient 33 | 50 (grad/cosine-coefficients (nth colors 2) (nth colors 0))))) 34 | 35 | (defn pth [coll fact low high] 36 | (nth coll (int (m/map-interval-clamped fact low high 0 (- (count coll) 1))))) 37 | 38 | (defn get-coloring-function [] 39 | (let [green-grad 0] 40 | (fn [n] 41 | (cond 42 | (< n -0.15) (pth grad1 n -1 -0.15) 43 | (< n 0.15) (pth grad2 n -0.15 0.15) 44 | (>= n 0.15) (pth grad3 n 0.15 1))))) 45 | 46 | (defn noise-function [coloring-function octaves scale turb] 47 | (fn [^"[[Lthi.ng.color.core.RGBA;" mt x y] 48 | (let [[x' y'] (turb x y) 49 | n (noise/octave-noise2 x' y' scale octaves) 50 | newcolor (coloring-function n)] 51 | (cm/aset2c mt x y newcolor)))) 52 | 53 | (defn draw [] 54 | (d/background 0 0 1 1) 55 | 56 | (cm/on-matrix (noise-function (get-coloring-function) 2 0.006 57 | (fn [x y] [x y]))) 58 | 59 | #_(cm/on-matrix 60 | (fn [^"[[Lthi.ng.color.core.RGBA;" mt x y] 61 | (cm/aset2c mt x y (pth my-grad (/ (/ (+ x y) 2) 500) 0.2 0.8)))) 62 | 63 | (cm/draw-matrix) 64 | 65 | (d/save "output.jpg")) 66 | 67 | -------------------------------------------------------------------------------- /src/staticart/sketch_8.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.sketch-8 2 | (:require [clojure.tools.trace :refer :all] 3 | [quil.core :as q :include-macros true] 4 | [staticart.color :as col] 5 | [staticart.color-matrix :as cm] 6 | [staticart.draw :as d] 7 | [staticart.generic-helper :refer :all] 8 | [staticart.noise :as noise] 9 | [staticart.settings :refer [settings]] 10 | [staticart.subdivision :as sub] 11 | [thi.ng.geom.core :as g] 12 | [thi.ng.geom.matrix :refer [M32]] 13 | [thi.ng.geom.triangle :as tri] 14 | [thi.ng.geom.utils :as gu] 15 | [thi.ng.geom.utils.delaunay :as del] 16 | [thi.ng.geom.vector :as v :refer [vec2]] 17 | [thi.ng.math.core :as m] 18 | [thi.ng.math.macros :as mm])) 19 | 20 | (defn get-coloring-function [] 21 | (let [grad1 (col/shuffled-random-grad col/palette_1 40) 22 | grad2 (col/shuffled-random-grad col/palette_1 40) 23 | grad3 (col/shuffled-random-grad col/palette_1 40)] 24 | (fn [n] 25 | (cond 26 | (< n -0.15) (pth grad1 n -1 -0.15) 27 | (< n 0.15) (pth grad2 n -0.15 0.15) 28 | (>= n 0.15) (pth grad3 n 0.15 1))))) 29 | 30 | (defn noise-function [coloring-function octaves scale turb] 31 | (let [r (rand 1000)] 32 | (fn [^"[[Lthi.ng.color.core.RGBA;" mt x y] 33 | (let [[x' y'] (map #(+ r %) (turb x y)) 34 | n (noise/octave-noise2 x' y' scale octaves) 35 | newcolor (coloring-function n)] 36 | (cm/aset2c mt x y newcolor))))) 37 | 38 | (defn draw [] 39 | 40 | (d/background 0 0 1 1) 41 | 42 | (let [oct (+ 1 (rand-int 4)) 43 | scale (+ 0.0005 (rand 0.001)) 44 | offset (+ 2 (rand-int 2))] 45 | 46 | (cm/on-matrix (noise-function (get-coloring-function) oct scale 47 | (fn [x y] [(* x 1) (* y (rand-int offset))])))) 48 | 49 | (cm/draw-matrix) 50 | 51 | (d/save (str "tmpout/output" (System/currentTimeMillis) ".tiff"))) 52 | 53 | -------------------------------------------------------------------------------- /src/staticart/sketch_9.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.sketch-9 2 | (:require [clojure.tools.trace :refer :all] 3 | [quil.core :as q :include-macros true] 4 | [staticart.color :as col] 5 | [staticart.color-matrix :as cm] 6 | [staticart.draw :as d] 7 | [staticart.generic-helper :refer :all] 8 | [staticart.noise :as noise] 9 | [staticart.random-helper :as rh] 10 | [staticart.screen-locations :refer :all] 11 | [staticart.settings :refer [settings]] 12 | [staticart.subdivision :as sub] 13 | [thi.ng.color.core :as c] 14 | [thi.ng.geom.core :as g] 15 | [thi.ng.geom.matrix :refer [M32]] 16 | [thi.ng.geom.triangle :as tri] 17 | [thi.ng.geom.utils :as gu] 18 | [thi.ng.geom.utils.delaunay :as del] 19 | [thi.ng.geom.vector :as v :refer [vec2]] 20 | [thi.ng.math.core :as m] 21 | [thi.ng.math.macros :as mm])) 22 | 23 | (defn function-points [f ps] 24 | (map #(vec2 % (f %)) ps)) 25 | 26 | (defn random-points [n] 27 | (repeatedly n #(vec2 (+ 0.4 (* 0.5 (rand))) (* 2 (Math/PI) (rand))))) 28 | 29 | (defn points-on-circle [n scale] 30 | (map #(vec2 (+ scale (* (rand) 0.05)) %) (range 0.0 m/TWO_PI (/ m/TWO_PI n)))) 31 | 32 | (defn to-cartesian [ps] 33 | (map g/as-cartesian ps)) 34 | 35 | (defn to-mid-screen [ps] 36 | (map #(m/+ screen-mid-point (scale-to-mid-screen %)) ps)) 37 | 38 | (defn scale-and-move [s m ps] 39 | (map #(m/+ m (m/* s %)) ps)) 40 | 41 | (defn curve-function [x] 42 | #_(Math/sin (* m/TWO_PI x (* (Math/sin (* x x 0.01)) m/TWO_PI)))(Math/sin (* x 8)) 43 | #_(Math/sin (* m/TWO_PI x (* (Math/sin (* x x 0.01)) m/TWO_PI))) 44 | (Math/sin (* m/TWO_PI (* (Math/sin (* (* (Math/sin x) 1.4) x x 0.2)) m/TWO_PI)))) 45 | 46 | (defn draw [] 47 | 48 | (d/background 1 1 1 1) 49 | 50 | (d/no-fill) 51 | ;;(apply d/fill (col/pick-color col/palette-soft1 0.2)) 52 | 53 | (d/stroke-weight (h 0.01)) 54 | 55 | (doseq [y (range -50 (+ 50 (h)) (h 0.005))] 56 | (apply d/stroke (deref (rand-nth col/palette_1))) 57 | (d/curve-through-points (scale-and-move (vec2 (h 0.2) (h 0.02)) (vec2 -50 y) 58 | (function-points curve-function (range 0.0 m/TWO_PI 0.05))))) 59 | ;; (d/curve-through-points (to-mid-screen (to-cartesian (points-on-circle 25 0.5))) true) 60 | ;; (doseq [p (to-mid-screen (to-cartesian (random-points 100)))] (d/debug-point) p) 61 | (d/save (str "tmpout/sketch_9_" (System/currentTimeMillis) ".tiff")) 62 | 63 | ) 64 | 65 | -------------------------------------------------------------------------------- /src/staticart/subdivision.clj: -------------------------------------------------------------------------------- 1 | (ns staticart.subdivision 2 | (:require [staticart.random-helper :as rh] 3 | [thi.ng.geom.core :as g] 4 | [thi.ng.math.core :as m])) 5 | 6 | (defn divide-triangle [[a b c]] 7 | (let [[p1 p2] (max-key #(apply g/dist %) [a b] [a c] [b c]) 8 | pm (m/mix p1 p2 (rh/gauss 0.5 0.1)) 9 | p3 (first (clojure.set/difference #{a b c} #{p1 p2}))] 10 | [[p3 p1 pm] [p3 p2 pm]])) 11 | 12 | (defn rec-divide-triangle [tri max-depth depth] 13 | (if (or (> 0.02 (rand)) (>= depth max-depth)) 14 | [tri] 15 | (let [tris (divide-triangle tri)] 16 | (mapcat #(rec-divide-triangle % max-depth (inc depth)) tris)))) 17 | 18 | (defn rec-divide-tris [tris max-depth] 19 | (mapcat #(rec-divide-triangle % max-depth 0) tris)) 20 | -------------------------------------------------------------------------------- /turb_noise_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/turb_noise_1.jpg -------------------------------------------------------------------------------- /turb_noise_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/turb_noise_2.jpg -------------------------------------------------------------------------------- /turb_noise_3_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/turb_noise_3_big.jpg -------------------------------------------------------------------------------- /turb_tris.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/turb_tris.jpg -------------------------------------------------------------------------------- /turb_tris_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/turb_tris_2.jpg -------------------------------------------------------------------------------- /turb_tris_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaminalder/staticart/079ac3e526a03a7f3f95b8981d3ee3d797f2e865/turb_tris_3.jpg --------------------------------------------------------------------------------