Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #r "System.Drawing.dll"
- open System.Drawing
- let colors = [
- 251, 226, 0
- 246, 180, 24
- 240, 81, 51
- 223, 43, 124
- 178, 36, 120
- 132, 37, 129
- 18, 37, 132
- 1, 73, 155
- 1, 134, 199
- 60, 161, 19
- 143, 181, 8
- 211, 209, 3 ]
- let pattern0 =
- [ 1,-2; 1,-1; 1, 0;
- 1, 1; 0, 1; -1, 1;
- -2, 1; -2, 0; -2,-1;
- -2,-2; -1,-2; 0,-2]
- let pattern1 =
- [-2, 1; -2, 0; -2,-1;
- -2,-2; -1,-2; 0,-2;
- 1,-2; 1,-1; 1, 0;
- 1, 1; 0, 1; -1, 1 ]
- let brushes =
- [for r,g,b in colors -> new SolidBrush(Color.FromArgb(255,r,g,b))]
- let width, height = 512,512
- let create n =
- let image = new Bitmap(width, height)
- use graphics = Graphics.FromImage(image)
- let mutable size = width/4
- let mutable i = 0
- while size > 0 do
- let d = size
- let n = if i%2 = 0 then n else -n
- if (i+n)%2 = 0 then pattern1 else pattern0
- |> List.iteri (fun i (x,y) ->
- let brush = brushes.[(12+i+n)%brushes.Length]
- graphics.FillRectangle(brush, 256 + (x*d), 256 + (y*d), d, d)
- )
- size <- size / 2
- i <- i + 1
- image
- (*
- #r "System.Windows.Forms.dll"
- open System.Windows.Forms
- let show () =
- let image = create 0
- let form = new Form (Text="boxes", Width=width, Height=height)
- let picture = new PictureBox(Dock=DockStyle.Fill, Image=image)
- do form.Controls.Add(picture)
- form.ShowDialog() |> ignore
- show()
- *)
- #r @"C:\Phil\Root\MLClass\MLClass\lib\Gif.Components.dll"
- open Gif.Components
- let encoder = AnimatedGifEncoder()
- if encoder.Start(@"c:\app\testA.gif") then
- //encoder.SetDelay(1000)
- encoder.SetFrameRate(2.0f)
- encoder.SetRepeat(0)
- for i = 0 to 11 do
- encoder.AddFrame(create i) |> ignore
- encoder.Finish() |> ignore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement