Commits

David Jones committed 0c311d8

got something working!

Comments (0)

Files changed (1)

SimpleGraphics.fs

         e.Graphics.TranslateTransform(width / 2.f, height/2.f)
         drawing_.Draw(e.Graphics)
         
-        
-
 module Drawings =
     let circle brush size =
         drawing (fun g ->
         drawing (fun gr ->
             f.Draw(gr)
             g.Draw(gr))
-        
-        
+
+    let inchToPixel x = int (100. * x)
+    let pixelToInch n = float n / 100.
+
+    let trans (x,y) =
+        System.Drawing.Point(inchToPixel x, -inchToPixel y)
+    
+    let transList = Array.map trans
+
+    let polygon brush points =
+        drawing (fun gr ->
+            let pts = transList points
+//            printfn "%A" pts
+            gr.FillPolygon(brush, pts)
+         )
+
+open Drawings
+
+let fillTri brush x y size =
+    polygon brush [|x,y;x+size,y;x,y-size;x,y|]
+
+let sierpinskiTri ms brush x y size =
+    let rec loop x y size =
+        if size < ms then fillTri brush x y size
+        else
+            let s2 = size / 2.
+            compose (loop x y s2)
+               (compose (loop x (y-s2) s2)
+                        (loop (x+s2) y s2))
+    loop x y size
 
 open Shapes
 
 
-
-
-type Graphic =
-    { brush: Brush;
-      f: (Form -> Brush -> unit);
-    }
+//type Graphic =
+//    { brush: Brush;
+//      f: (Form -> Brush -> unit);
+//    }
     
 
 // Draw a graphic g into a window w.
 // We want to compose graphics (Alter colors, etc...)
 
 
-let withColor x g =
-    {g with brush = x}
+//let withColor x g =
+//    {g with brush = x}
     
+(*
     
 let drawInWindow w g =
     g.f w g.brush
    g.DrawString(s, font, brush, x, y, format)
 
 
-let keyDown (f:Form) =
-    f.KeyDown
-    |> Observable.map (fun k ->
-        char k.KeyValue)
-
     
-let untilSpace (f:Form) =
-    f.KeyDown
-    |> Observable.add (fun k ->
-        if k.KeyValue = int ' ' then
-            f.Close())
-
-    
-let run f =
-    untilSpace f
-    while not f.IsDisposed do
-        Application.DoEvents()
-        
-    
+*)