3 people like it.

Draw rectangle in TryFSharp.org

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
open System
open System.Windows
open System.Windows.Controls
open System.Windows.Media
open System.Windows.Shapes
open Microsoft.TryFSharp


let line (x1, y1) (x2, y2) =
    App.Dispatch(fun () ->
        let s = new Line(X1=x1, Y1=y1, X2=x2, Y2=y2)
        s.Stroke <- new SolidColorBrush(Colors.Black)
        App.Console.Canvas.Children.Add s
    ) |> ignore

let rectangle (x1, y1) (x2, y2) (x3, y3) (x4, y4) =
    line (x1, y1) (x2, y2)
    line (x2, y2) (x3, y3)
    line (x3, y3) (x4, y4)
    line (x4, y4) (x1, y1)

rectangle (20.0, 200.0) (20.0, 400.0) (200.0, 400.0) (200.0, 200.0)
namespace System
namespace System.Windows
namespace System.Media
namespace Microsoft
val line : x1:'a * y1:'b -> x2:'c * y2:'d -> unit

Full name: Script.line
val x1 : 'a
val y1 : 'b
val x2 : 'c
val y2 : 'd
type Console =
  static member BackgroundColor : ConsoleColor with get, set
  static member Beep : unit -> unit + 1 overload
  static member BufferHeight : int with get, set
  static member BufferWidth : int with get, set
  static member CapsLock : bool
  static member Clear : unit -> unit
  static member CursorLeft : int with get, set
  static member CursorSize : int with get, set
  static member CursorTop : int with get, set
  static member CursorVisible : bool with get, set
  ...

Full name: System.Console
val ignore : value:'T -> unit

Full name: Microsoft.FSharp.Core.Operators.ignore
val rectangle : x1:'a * y1:'b -> x2:'c * y2:'d -> x3:'e * y3:'f -> x4:'g * y4:'h -> unit

Full name: Script.rectangle
val x3 : 'e
val y3 : 'f
val x4 : 'g
val y4 : 'h
Raw view Test code New version

More information

Link:http://fssnip.net/6v
Posted:14 years ago
Author:
Tags: