Skip to content

Instantly share code, notes, and snippets.

View edap's full-sized avatar

Davide Prati edap

View GitHub Profile
def qsort(l)
return l if l.length <= 1
pivot = l.sample
lft, rgt = l.partition {|e| e < pivot}
qsort(lft).concat(qsort(rgt))
end
func isImage(filename string) bool {
is_img, _ := regexp.MatchString("(?i)\\.(png|jpg|jpeg|gif)$", filename)
return is_img
}

install this: https://github.com/parkr/ruby-build-github

And then install the ruby version 2.1.7 rbenv install 2.1.7-github

go in the folder of your website. Run:

rbenv local 2.1.7-github

This will set the ruby version of your project to 2.1.7.

(defn da-example-apply-recursively
[]
(let [hex (mg/apply-recursively (mg/reflect :e) 5 [1] 1)
seed (a/aabb [0 0 0] 0.95)
tree (mg/skew
:n
:e
:offset 0.3
:out [hex])
]
(defn morphogen-mesh
[seed tree]
(-> seed
(mg/seed-box)
(mg/generate-mesh tree)
(g/center)))
(def strip-quad
"Arrangement of quads"
(let [quad (mg/apply-recursively (mg/reflect :e) 4 [1] 1)
@edap
edap / star.cljs
Last active August 11, 2016 21:02
(defn star
[]
(let [side (mg/apply-recursively (mg/reflect :e) 13 [1] 1)
seed (mg/sphere-lattice-seg 6 0.355 0.0955 0.2)
skewed-side (mg/skew
:n
:e
:offset 0.3
:out [side])
tree (mg/scale-edge
@edap
edap / spritz.clj
Last active August 25, 2016 04:33
(defn punch
{:op :sd-inset, :args {:dir :w, :inset 0.999}, :out [{} {} {} {} nil]}
[dir w & [out]]
(mg/subdiv-inset :dir dir :inset w :out (or out {4 nil})))
(defn petal
[scale offset punch-y]
(let [punch-it (mg/skew :e :e :offset offset
:out [(punch :y punch-y)])
tree (mg/scale-edge :ef :y :scale scale
(defn scale-side
[hex distorsion]
(mg/scale-edge :ef :y
:scale distorsion
:out [hex]))
(defn displace-ring
[& {:keys [offset scale] :or {offset 0.2 scale 1.0}}]
(let [displace-it (mg/split-displace :y :z :offset offset :out [nil {}])
scale-it (mg/scale-edge :bc :z :scale scale :out [displace-it])]
(defn leaf
[n-stripes width]
(let [
end (mg/scale-edge :ab :x
:scale 0.02
:out [(make-stripes n-stripes)])
middle (mg/reflect :s :out[{}
(mg/scale-edge :bc :z
:len width
:out [(mg/extrude
Tech Toolbox
http://www.gdcvault.com/play/1024145/Tech
Practical Procedural Generation for Everyone
http://www.gdcvault.com/play/1024213/Practical-Procedural-Generation-for
Building Worlds Using Math(s)
http://www.gdcvault.com/play/1024514/Building-Worlds-Using