F# Geometry types
type Rect =
{ Left:int; Top:int; Width:int; Height:int }
with
static member create(w, h) = { Left=0; Top=0; Width=w; Height=h }
static member create(l,t,r,b) = { Left=l; Top=t; Width=(r-l)+1; Height=(b-t)+1 }
static member shrink n r = { Left=r.Left+n; Top=r.Top+n; Width=r.Width-2*n; Height=r.Height-2*n }
static member scan r =
seq {
for y = r.Top to r.Top+r.Height-1 do
for x = r.Left to r.Left+r.Width-1 do
yield x,y
}