View
2.164
Download
5
Category
Preview:
DESCRIPTION
Slides from hands on Generative Art with F# session for the F#unctional Londoners meetup group at Skills Matter
Citation preview
Generative ArtPhillip Trelford
F#unctional Londoners
2013
Generative Art: Que?
Generative artists are chaos artists
…embrace the chaos & learn to love it
Modern Art: Procedurally Generated
Modern Art: Animated
Animated Gifs
Happy endings
// Generate text from Philippe Decrauzat's D.T.A.B.T.W.H.A.H.E. 2010
let print (s:string) =
[|for y in 0..s.Length-1 ->
[|for x in 0..y-1 -> s.[x]
for x in y..s.Length-1 -> s.[y]
|]
|> fun cs ->
System.String(cs) +
System.String(cs |> Array.rev |> Seq.skip 1 |> Seq.toArray)
|]
|> fun ys -> [|yield! ys; yield! (Array.rev ys |> Seq.skip 1)|]
|> String.concat "\r\n"
print "A HAPPY ENDING"
Choose your own adventure
SmallSharp: Lines
open Library
do GraphicsWindow.Show()
GraphicsWindow.BrushColor <- red
for i in 0..5..200 do
GraphicsWindow.DrawLine(i,0,n-i,n)
GraphicsWindow.DrawLine(0,i,n,n-i)
Deviant Art: Bubbles
Rothko / Async Rectangles
let rec waiting() = async {
let! md = Async.AwaitObservable(main.MouseLeftButtonDown)
let rc = new Canvas(Background = transparentGray)
main.Children.Add(rc)
do! drawing(rc, md.GetPosition(main)) }
and drawing(rc:Canvas, pos) = async {
let! evt = Async.AwaitObservable(main.MouseLeftButtonUp, main.MouseMove)
match evt with
| Choice1Of2(up) ->
rc.Background <- SolidColorBrush(colorSelect.CurrentColor)
do! waiting()
| Choice2Of2(move) ->
moveControl rc pos (move.GetPosition(main))
do! drawing(rc, pos) }
Mandelbrot
let (|Escaped|DidNotEscape|) (cx,cy) =
let rec compute (zx,zy) i =
if i = maxIteration then DidNotEscape
elif zx * zx + zy * zy > 4.0 then Escaped i
else compute (zx*zx - zy*zy + cx, 2.0*zx * zy + cy) (i+1)
compute (cx,cy) 0
Turing Drawings
match action with
| Action.Left ->
xPos <- xPos + 1
if xPos >= mapWidth then xPos <- xPos - mapWidth
| Action.Right ->
xPos <- xPos - 1
if (xPos < 0) then xPos <- xPos + mapWidth
| Action.Up ->
yPos <- yPos - 1
if (yPos < 0) then yPos <- yPos + mapHeight
| Action.Down ->
yPos <- yPos + 1
if yPos >= mapHeight then yPos <- yPos - mapHeight
Inspirational Sites
This is Colossal Deviant Art Zen Bullets
F# Libraries
http://smallsharp.codeplex.com (Graphics)
http://funscript.info (F# -> JS)
http://www.pinksquirrellabs.com (CYAO Type Provider)
Recommended