PatterningInCardiganBay

ThoughtStorms Wiki

CardiganBay, the software behind this wiki now supports a card type of basic Patterning patterns. You can learn more about Patterning here : http://alchemyislands.com/tutorials/HelloWorld.html

Cards, of type :patterning, can be used to make patterns. You can see some examples below.

Note that the embedded SVG in these cards was generated from Patterning at ExportTime


; Make a ring of polygons. Same number of polygons as number of sides.

(defn a-round
  [n style]
  (clock-rotate
     n (poly 0 0.5 0.2 n style)))

(a-round 5 {:stroke (p-color 220 140 180)
            :fill (p-color 190 55 250 100) })

;; Fill a grid layout from a repeated stream of those a-rounds

(defn a-round
  [n style]
  (clock-rotate
     n (poly 0 0.5 0.2 n style)))

(grid-layout 3
  (repeat
    (a-round 5 {:stroke (p-color 220 140 180)
                :fill (p-color 190 255 200 100) })
  )
)

;; Use a half-drop-grid-layout to stagger two different patterns
;; We use a cycle to create an alternating stream of them

(defn a-round
  [n style]
  (clock-rotate
     n (poly 0 0.5 0.2 n style)))

(half-drop-grid-layout 6
(cycle [
 (a-round 6 {:stroke (p-color 140 220 180) 
             :fill (p-color 190 255 200 100) 
             :stroke-weight 2}
 )
 (a-round 9 {:fill (p-color 255 100 100 ) 
             :stroke (p-color 190 255 200 100) 
             :stroke-weight 2}
 )]))

;; Map a colour randomizing function across a stream of 
;; a-rounds, generated from a cycle of different numbers

(defn rand-col [] (p-color (rand-int 255) (rand-int 255) (rand-int 255) ))

(defn a-round
  [n style]
  (clock-rotate
     n (poly 0 0.5 0.2 n style)))

(let
 [rand-color
  (fn [p]
   (let
    [c (rand-col)]
    (over-style
     {:fill c, :stroke-weight 2, :stroke (darker-color c)}
     p)))]
 (grid-layout
  8 
  (map rand-color (map #(a-round % {}) (cycle [3 4 5 6 7])))))

;; Use a framed layout which takes 3 patterns, representing 
;; corners, edges and centre-piece

(let
 [corner
  (stack
   (square {:fill (p-color 255 0 0 100)})
   (poly 0 0 0.9 4 {:fill (p-color 240 100 240)}))
  edge
  (stack
   (square {:fill (p-color 0 0 255)})
   (poly 0 0 0.5 8 {:fill (p-color 150 150 255)}))
  centre
  (poly 0 0 0.9 30 {:fill (p-color 150 255 140)})]
 (framed 11 (repeat corner) (repeat edge) centre))

;; use random-turn-groups to make a stream of patterns 
;; randomly rotated, and then lay them out in a grid.

(let
 [orange (p-color 254 129 64)]
 (stack
  (square {:fill (p-color 50 80 100)})
  (checked-layout
   18
   (cycle
    [(clock-rotate
      8
      (drunk-line 10 0.1 {:stroke orange, :stroke-weight 1}))
     (clock-rotate
      5
      (drunk-line 10 0.1 {:stroke orange, :stroke-weight 2}))])
   (random-turn-groups
    (repeat
     [(->SShape
       {:fill (p-color 230 180 90), :stroke orange}
       [[-1 -1] [1 -1] [-1 1]])])))))

(defn a-round
  [n style]
  (clock-rotate
     n (poly 0 0.5 0.4 n style)))

(->
 (let
  [lc (p-color 220 140 180) fc (p-color 255 190 200 100)]
  (grid-layout
   4 
   (iterate (partial scale 0.9) (a-round 9 {:stroke lc :fill fc})
   )
  )
 )
 v-reflect
)

; This makes a scroll using Patterning's built in Turtle
; and then reflects that to make a "vase" pattern (when the params are right)
; In this case though we run through a range of params, giving us everything 
; from vases to very different scrolls and knots

(def PI 3.14159265358979)

(defn f-left [count]
  (cond (= count 1) "F"
        :else (str (f-left (- count 1)) "+" (apply str (repeat count "F" )) )) )

(defn f-right [count]
  (cond (= count 1 ) "F"
        :else (str (apply str (repeat count "F" )) "-" (f-right (- count 1)))))

(defn all [count] (str (f-left count) "-" (f-right (- count 1)) ) )

(defn scroll [[x y] d da number style extras]
  (basic-turtle [x y] d 0 da (all number) extras style ))

(defn r-scroll [d da number style extras] (reframe (scroll [0 0] d da number
                                      style extras) ))

(defn vase [d da count style]
  (let [scroll (r-scroll d da count style {})]
    (stack scroll (v-reflect scroll) )))


(defn fr [count]
 ( ->
    (vase 0.1 0.25 count {:stroke (p-color 0 0 0)}) 
    (#(rotate (/ PI 2) %))
   four-round
   (#(scale 0.7 %)) 
 
))

(grid-layout 5 (map fr (range 5 30 1)))

Backlinks (2 items)