5 people like it.

Simple example of cross platform Eto forms library

Simple example of Eto library usage for drawing

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
open Eto.Forms
open Eto.Drawing


let app = new Application()

let mutable dir = 1
let mutable k = 0

let d = new Drawable()

let t = new UITimer()
t.Interval <- 0.1
t.Elapsed.Add(fun _ -> k <- k+dir; d.Invalidate())

d.Paint.Add(fun e ->
  let g = e.Graphics
  g.ScaleTransform(1.f, -1.f)
  g.TranslateTransform(0.f, -single(d.Size.Height))
  let n = d.Size.Height / 10
  let h = single(n * 10)
  if k = n || k = -1 then dir <- dir * -1
  for c in 0 .. (min k (n - 1)) do
    let x = single(c)*10.f
    g.DrawLine(Colors.Black, 0.f, h - x, x + 10.f, 0.f)
)

let f = new Form(Topmost=true, ClientSize = new Size(600, 480))
f.Content <- d
f.Show()

f.Shown.Add(fun _ -> t.Start())
val app : obj

Full name: Script.app
val mutable dir : int

Full name: Script.dir
val mutable k : int

Full name: Script.k
val d : obj

Full name: Script.d
val t : obj

Full name: Script.t
Multiple items
val single : value:'T -> single (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.single

--------------------
type single = System.Single

Full name: Microsoft.FSharp.Core.single
val min : e1:'T -> e2:'T -> 'T (requires comparison)

Full name: Microsoft.FSharp.Core.Operators.min
val f : obj

Full name: Script.f
Raw view Test code New version

More information

Link:http://fssnip.net/og
Posted:9 years ago
Author:Antonio Cisternino
Tags: drawing , gui , eto