Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #r "System.Drawing.dll"
- #r "System.Windows.Forms.dll"
- open System
- open System.Drawing
- open System.Windows.Forms
- let width, height = 512, 512
- let blue = (2, 89, 148)
- let yellow = (252, 173, 6)
- let red = (200, 1, 44)
- let purple = (116, 56, 119)
- let pattern w h = [
- (-1, 0), (0,0);
- ( 0, 1), (0,h-1);
- ( 1, 0), (w-1,h-1);
- ( 0,-1), (w-1,4)
- (-1, 0), (4,4)
- ]
- let path w h =
- let x, y = ref (w-1), ref 0
- [for (dx,dy), (x1,y1) in pattern w h do
- while !x <> x1 || !y <> y1 do
- yield !x,!y
- x := !x + dx
- y := !y + dy
- ]
- let draw () =
- let image = new Bitmap(width, height)
- use graphics = Graphics.FromImage(image)
- let color = Color.FromArgb(255,234,236,232)
- let brush = new SolidBrush(color)
- graphics.FillRectangle(brush, 0, 0, width, height)
- let colors = [blue; yellow; red; purple]
- for i = 0 to 3 do
- let w,h = 25-i*2, 25 - i*2
- let points = path w h
- let n = points.Length
- for (x,y) in points |> Seq.take (n-(i+2)*1) |> Seq.skip ((3-i)*3) do
- let r,g,b = colors.[i]
- let color = Color.FromArgb(255,r,g,b)
- let brush = new SolidBrush(color)
- graphics.FillRectangle(brush, (1+x+i)*19, (1+y+i)*19, 19, 19)
- image
- let show () =
- let image = draw ()
- let form = new Form (Text="Loewensberg Lines", Width=320+16, Height=320+36)
- let picture = new PictureBox(Dock=DockStyle.Fill, Image=image)
- image.Save(@"C:\temp\Loewensberg Lines.png", Imaging.ImageFormat.Png)
- do form.Controls.Add(picture)
- form.ShowDialog() |> ignore
- show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement