Skip to content

Instantly share code, notes, and snippets.

@SoulFireMage
Last active January 13, 2016 14:13
Show Gist options
  • Save SoulFireMage/8149557 to your computer and use it in GitHub Desktop.
Save SoulFireMage/8149557 to your computer and use it in GitHub Desktop.
Learning Snippets
//Totally unnecessary implementation of course but attempting to implement one's own graphics also means
//getting to play with the idioms and datastructures of a language IMHO
//I might implement Logo in here someday :).
let square (x,y) length = [ (x,y,x+length,y); //top
(x,y+length,x+length,y+length); //bottom
(x,y,x ,y + length ); //left
(x + length,y,x + length, y + length )] //right
let showForm() =
let form = new Form(TopMost = true, ClientSize = new Size(600,400))
let g() = form.CreateGraphics()
let s = (square (100,100) 180)
form.Show()
form.Paint.Add(fun pe -> for side in s do
let x1,y1,x2,y2 = side
pe.Graphics.DrawLine(Pens.Black, x1,y1,x2,y2)
)
showForm()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment