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.Drawing.Drawing2D
- open System.Windows.Forms
- let width, height = 512, 512
- let white = 229,233,225
- let yellow = 230, 202, 59
- let sand = 224, 158, 1
- let orange = 240, 104, 54
- let red = 234, 67, 78
- let blue1 = 122, 139, 254
- let blue2 = 138, 121, 213
- let purple = 166, 114, 192
- let toPen (r,g,b) =
- new Pen(Color.FromArgb(255,r,g,b))
- let toBrush (r,g,b) =
- let color = Color.FromArgb(255,r,g,b)
- new SolidBrush(color)
- let draw (n1:int) (n2:int) =
- let image = new Bitmap(width, height)
- use graphics = Graphics.FromImage(image)
- graphics.SmoothingMode <- System.Drawing.Drawing2D.SmoothingMode.AntiAlias
- let brush = toBrush white
- graphics.FillRectangle(brush, 0, 0, width, height)
- [yellow;sand;orange;red;white]
- |> List.iteri (fun i color ->
- let brush = toBrush color
- let k = 40+i*30
- graphics.FillPie(brush,k,k,width-k*2,height-k*2,0,360)
- )
- [red; purple; blue2; blue1 ;white]
- |> List.iteri (fun i color ->
- let brush = toBrush color
- let k = 40+i*30
- let path = new GraphicsPath()
- path.AddLine(0,512, 0, 100)
- let x1, x2 = k+30+n1, k-30-n2+(width-k*2)
- path.AddLine(x1 , 0, x1 ,256)
- path.AddLine(x1 ,256, x2 ,256)
- path.AddLine(x2 ,256, x2 , 0)
- path.AddLine(x2 , 0, 512, 0)
- path.AddLine(512, 0, 512,512)
- graphics.SetClip(path)
- graphics.FillPie(brush,k,k,width-k*2,height-k*2,0,360)
- )
- let brush = toBrush white
- let k = 40+4*30
- graphics.FillPie(brush,k,k,width-k*2,height-k*2,0,360)
- image
- let show () =
- let image = draw 30 30
- let form = new Form (Text="Loewensberg Lines", Width=width+16, Height=height+36)
- let picture = new PictureBox(Dock=DockStyle.Fill, Image=image)
- image.Save(@"C:\app\Loewensberg Square.png", Imaging.ImageFormat.Png)
- do form.Controls.Add(picture)
- form.ShowDialog() |> ignore
- //show()
- #r @"Gif.Components.dll"
- open Gif.Components
- let encoder = AnimatedGifEncoder()
- if encoder.Start(@"c:\temp\Loewensberg circles shakeup.gif") then
- encoder.SetFrameRate(20.0f)
- encoder.SetRepeat 0
- for n = 0 to 15 do
- encoder.AddFrame(draw (15+n) (15-n)) |> ignore
- for n = 15 downto -15 do
- encoder.AddFrame(draw (15+n) (15-n)) |> ignore
- for n = -15 to 0 do
- encoder.AddFrame(draw (15+n) (15-n)) |> ignore
- for n = 15 to 45 do
- encoder.AddFrame(draw (n) (n)) |> ignore
- for n = 45 downto 0 do
- encoder.AddFrame(draw (n) (n)) |> ignore
- for n = 0 to 15 do
- encoder.AddFrame(draw (n) (n)) |> ignore
- encoder.Finish() |> ignore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement