Skip to content
Browse files

Demo patchers.

  • Loading branch information...
1 parent 30a2118 commit 6eac5c37be08b7fe9c87914dad1eb69df5fcbfc2 @cassiel committed Jun 2, 2012
Showing with 180 additions and 30 deletions.
  1. +26 −2 README.md
  2. +30 −7 patchers/GRIDSTATE.maxpat
  3. +103 −9 patchers/INTERACTION.maxpat
  4. +9 −1 patchers/set-only.clj
  5. +12 −11 trails/4-STATE.md
View
28 README.md
@@ -14,8 +14,8 @@ The file of patchers and Clojure script files
(`maxmsp-clojure-expo74.zip`) goes into the `patches` folder for
Max (or anywhere in Max's search path).
-Downloads available under this GitHub project if you have an account; otherwise, all
-available from [Dropbox][dropbox].
+Downloads available under this GitHub project if you have an account;
+otherwise, all available from [Dropbox][dropbox].
## Java
@@ -27,12 +27,33 @@ Terminal window prompts to start the installation process.
For Windows, Java is downloadable from [Oracle][java]. The JRE (Java
Runtime) will probably work, but I tested with the JDK.
+## Getting Started
+
+The directory `trails` contains README files for a set of tutorials;
+corresponding patchers are in the directory `patchers`. The directory
+`DONE` contains completed exercises.
+
+More advanced examples can be found in the
+source [net.loadbang.clojure][nl-clojure] project.
+
## Other Software
* Windows text editor: [Notepad++][npp] - supports editing of Lisp source.
* OS X text editor: [TextMate][tm] - supports bracket matching.
* Either platform: [jEdit][jedit] - native Java application.
+## Original Sources
+
+All the `net.loadbang` sources are on GitHub:
+
+* [net.loadbang.clojure][nl-clojure]
+* [net.loadbang.scripting][nl-scripting]
+* [net.loadbang.lib][nl-lib]
+
+The other dependent libraries (`log4j`, and Clojure itself) are pulled
+in via Maven in the build process; sources are also available for
+these.
+
## Online Resources
* [Lisp (Wikipedia)][wlisp].
@@ -47,3 +68,6 @@ Runtime) will probably work, but I tested with the JDK.
[tm]: http://macromates.com
[jedit]: http://www.jedit.org
[dropbox]: http://dl.dropbox.com/u/2546860/expo74-clojure-all.zip
+[nl-clojure]: https://github.com/cassiel/net.loadbang.clojure
+[nl-scripting]: https://github.com/cassiel/net.loadbang.scripting
+[nl-lib]: https://github.com/cassiel/net.loadbang.lib
View
37 patchers/GRIDSTATE.maxpat
@@ -4,10 +4,10 @@
"appversion" : {
"major" : 6,
"minor" : 0,
- "revision" : 3
+ "revision" : 4
}
,
- "rect" : [ 25.0, 50.0, 809.0, 793.0 ],
+ "rect" : [ 43.0, 50.0, 694.0, 793.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
@@ -54,10 +54,10 @@
"appversion" : {
"major" : 6,
"minor" : 0,
- "revision" : 3
+ "revision" : 4
}
,
- "rect" : [ 729.0, 179.0, 396.0, 252.0 ],
+ "rect" : [ 546.0, 101.0, 558.0, 418.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
@@ -81,6 +81,20 @@
"box" : {
"fontname" : "Anonymous Pro",
"fontsize" : 12.0,
+ "id" : "obj-3",
+ "maxclass" : "message",
+ "numinlets" : 2,
+ "numoutlets" : 1,
+ "outlettype" : [ "" ],
+ "patching_rect" : [ 250.0, 70.0, 56.0, 16.0 ],
+ "text" : "(clear)"
+ }
+
+ }
+, {
+ "box" : {
+ "fontname" : "Anonymous Pro",
+ "fontsize" : 12.0,
"id" : "obj-8",
"maxclass" : "message",
"numinlets" : 2,
@@ -158,6 +172,15 @@
"destination" : [ "obj-11", 0 ],
"disabled" : 0,
"hidden" : 0,
+ "source" : [ "obj-3", 0 ]
+ }
+
+ }
+, {
+ "patchline" : {
+ "destination" : [ "obj-11", 0 ],
+ "disabled" : 0,
+ "hidden" : 0,
"source" : [ "obj-5", 0 ]
}
@@ -252,21 +275,21 @@
],
"dependency_cache" : [ {
"name" : "g64c.Grid.maxpat",
- "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers/patchers",
+ "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers",
"patcherrelativepath" : "",
"type" : "JSON",
"implicit" : 1
}
, {
"name" : "g64c.Column.maxpat",
- "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers/patchers",
+ "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers",
"patcherrelativepath" : "",
"type" : "JSON",
"implicit" : 1
}
, {
"name" : "g64c.Cell.maxpat",
- "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers/patchers",
+ "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers",
"patcherrelativepath" : "",
"type" : "JSON",
"implicit" : 1
View
112 patchers/INTERACTION.maxpat
@@ -4,10 +4,10 @@
"appversion" : {
"major" : 6,
"minor" : 0,
- "revision" : 3
+ "revision" : 4
}
,
- "rect" : [ 110.0, 47.0, 694.0, 793.0 ],
+ "rect" : [ 39.0, 49.0, 694.0, 780.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
@@ -53,10 +53,10 @@
"appversion" : {
"major" : 6,
"minor" : 0,
- "revision" : 3
+ "revision" : 4
}
,
- "rect" : [ 509.0, 86.0, 775.0, 330.0 ],
+ "rect" : [ -18.0, 55.0, 1118.0, 478.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
@@ -75,16 +75,74 @@
"description" : "",
"digest" : "",
"tags" : "",
+ "visible" : 1,
"boxes" : [ {
"box" : {
"fontname" : "Anonymous Pro",
"fontsize" : 12.0,
+ "id" : "obj-7",
+ "linecount" : 2,
+ "maxclass" : "message",
+ "numinlets" : 2,
+ "numoutlets" : 1,
+ "outlettype" : [ "" ],
+ "patching_rect" : [ 115.0, 155.0, 653.0, 28.0 ],
+ "text" : "(defn click [cx cy] (fundraw (fn [x y] (or (and (= cx x) ( <= (Math/abs (- cy y )) 2)) (and (= cy y) ( <= (Math/abs (- cx x )) 2))))))"
+ }
+
+ }
+, {
+ "box" : {
+ "fontname" : "Anonymous Pro",
+ "fontsize" : 12.0,
+ "id" : "obj-5",
+ "maxclass" : "message",
+ "numinlets" : 2,
+ "numoutlets" : 1,
+ "outlettype" : [ "" ],
+ "patching_rect" : [ 125.0, 120.0, 194.0, 16.0 ],
+ "text" : "(defn hover [hx hy how] nil)"
+ }
+
+ }
+, {
+ "box" : {
+ "fontname" : "Anonymous Pro",
+ "fontsize" : 12.0,
+ "id" : "obj-3",
+ "maxclass" : "message",
+ "numinlets" : 2,
+ "numoutlets" : 1,
+ "outlettype" : [ "" ],
+ "patching_rect" : [ 95.0, 205.0, 568.0, 16.0 ],
+ "text" : "(defn click [cx cy] (fundraw (fn [x y] (= (Math/abs (- cx x)) (Math/abs (- cy y))))))"
+ }
+
+ }
+, {
+ "box" : {
+ "fontname" : "Anonymous Pro",
+ "fontsize" : 12.0,
+ "id" : "obj-2",
+ "maxclass" : "message",
+ "numinlets" : 2,
+ "numoutlets" : 1,
+ "outlettype" : [ "" ],
+ "patching_rect" : [ 45.0, 75.0, 378.0, 16.0 ],
+ "text" : "(defn hover [hx hy how] ( fundraw (fn [x y] (= hx x ))))"
+ }
+
+ }
+, {
+ "box" : {
+ "fontname" : "Anonymous Pro",
+ "fontsize" : 12.0,
"id" : "obj-6",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
- "patching_rect" : [ 60.0, 130.0, 463.0, 16.0 ],
+ "patching_rect" : [ 70.0, 95.0, 463.0, 16.0 ],
"text" : "(defn hover [hx hy how] (fundraw (fn [x y] (and (= hx x) (= hy y)))))"
}
@@ -98,7 +156,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
- "patching_rect" : [ 110.0, 60.0, 568.0, 16.0 ],
+ "patching_rect" : [ 130.0, 25.0, 568.0, 16.0 ],
"text" : "(defn click [cx cy] (fundraw (fn [x y] (if (or (= x cx) (= y cy)) [1 0 0] [0 0 0]))))"
}
@@ -120,6 +178,24 @@
"destination" : [ "obj-11", 0 ],
"disabled" : 0,
"hidden" : 0,
+ "source" : [ "obj-2", 0 ]
+ }
+
+ }
+, {
+ "patchline" : {
+ "destination" : [ "obj-11", 0 ],
+ "disabled" : 0,
+ "hidden" : 0,
+ "source" : [ "obj-3", 0 ]
+ }
+
+ }
+, {
+ "patchline" : {
+ "destination" : [ "obj-11", 0 ],
+ "disabled" : 0,
+ "hidden" : 0,
"source" : [ "obj-4", 0 ]
}
@@ -129,10 +205,28 @@
"destination" : [ "obj-11", 0 ],
"disabled" : 0,
"hidden" : 0,
+ "source" : [ "obj-5", 0 ]
+ }
+
+ }
+, {
+ "patchline" : {
+ "destination" : [ "obj-11", 0 ],
+ "disabled" : 0,
+ "hidden" : 0,
"source" : [ "obj-6", 0 ]
}
}
+, {
+ "patchline" : {
+ "destination" : [ "obj-11", 0 ],
+ "disabled" : 0,
+ "hidden" : 0,
+ "source" : [ "obj-7", 0 ]
+ }
+
+ }
],
"dependency_cache" : [ ]
}
@@ -223,21 +317,21 @@
],
"dependency_cache" : [ {
"name" : "g64c.Grid.maxpat",
- "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers/patchers",
+ "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers",
"patcherrelativepath" : "",
"type" : "JSON",
"implicit" : 1
}
, {
"name" : "g64c.Column.maxpat",
- "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers/patchers",
+ "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers",
"patcherrelativepath" : "",
"type" : "JSON",
"implicit" : 1
}
, {
"name" : "g64c.Cell.maxpat",
- "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers/patchers",
+ "bootpath" : "/Users/nick/CASSIEL-GIT/maxmsp-clojure-expo74/patchers",
"patcherrelativepath" : "",
"type" : "JSON",
"implicit" : 1
View
10 patchers/set-only.clj
@@ -7,5 +7,13 @@
(defn draw [state]
(fundraw (fn [x y] (get state [x y]))))
+(defn clear []
+ (draw (swap! the-state (fn [old] { } ))))
+
+;(defn click [x y]
+; (draw (swap! the-state (fn [old] (assoc old [x y] true)))))
+
(defn click [x y]
- (draw (swap! the-state (fn [old] (assoc old [x y] true)))))
+ (draw (swap! the-state
+ (fn [old] (assoc (assoc old [x y] true)
+ [(- 7 x) y] true)))))
View
23 trails/4-STATE.md
@@ -4,25 +4,26 @@ Clojure wants to be purely functional - "variables" cannot be updated.
Updatable variables must be created specially as *atoms*:
- (def the-state (atom 0))
+ (def the-state (atom 0))
Atom values are accessed by *dereferencing*
- (deref the-state)
- @the-state
+ (deref the-state)
+ @the-state
An atom's value is changed by applying a function to its old value:
- (swap! the-state (fn [x] (* x 2)))
- (swap! the-state inc)
+ (swap! the-state (fn [x] (* x 2)))
+ (swap! the-state inc)
This is done as a *transaction*.
-An atom can contain a complex data structure - and an update function can partially alter it.
+An atom can contain a complex data structure - and an update function
+can partially alter it.
- (def the-state (atom []))
+ (def the-state (atom []))
- (swap! the-state (fn [x] (conj x 2)))
- (swap! the-state (fn [x] (conj x (rand))))
- (swap! the-state pop)
- (swap! the-state (fn [x] (vec (map inc x))))
+ (swap! the-state (fn [x] (conj x 2)))
+ (swap! the-state (fn [x] (conj x (rand))))
+ (swap! the-state pop)
+ (swap! the-state (fn [x] (vec (map inc x))))

0 comments on commit 6eac5c3

Please sign in to comment.
Something went wrong with that request. Please try again.