Advertisement
ptrelford

SECHS SERIGRAPHIEN

Oct 21st, 2014
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.21 KB | None | 0 0
  1. // http://www.mutualart.com/Artwork/6-WORKS--SECHS-SERIGRAPHIEN/540343E9E4091FCC
  2. // Richard Paul Lohse: SECHS SERIGRAPHIEN
  3.  
  4. let design = """YYYYYYYYYB
  5. PPPPPPPPYB
  6. PRPYYYYYYB
  7. PRPPPPYBYB
  8. PRPRBRYBYB
  9. PRPRYPYBYB
  10. PRPRBBBBYB
  11. PRRRRRRBYB
  12. PRBBBBBBBB
  13. PRRRRRRRRR"""
  14.  
  15.  
  16. #r "System.Drawing.dll"
  17. #r "System.Windows.Forms.dll"
  18.  
  19. open System
  20. open System.Drawing
  21. open System.Windows.Forms
  22.  
  23. let toColor = function
  24.    | 'R' -> Color.FromArgb(255,245,117,26)
  25.    | 'Y' -> Color.FromArgb(255,238,241,0)
  26.    | 'P' -> Color.FromArgb(255,161,129,228)
  27.    | 'B' -> Color.FromArgb(255,80,170,241)
  28.    | _ -> Color.White
  29.  
  30. let toBrush c = new SolidBrush(toColor c) :> Brush
  31.  
  32. let show () =
  33.    let form = new Form (Text="SECHS SERIGRAPHIEN", Width=320+16, Height=320+36)  
  34.    let image = new Bitmap(form.Width, form.Height)
  35.    let picture = new PictureBox(Dock=DockStyle.Fill, Image=image)
  36.    do  form.Controls.Add(picture)
  37.    use graphics = Graphics.FromImage(image)
  38.    let lines = design.Split([|'\n'|])
  39.    lines |> Seq.iteri (fun y line ->
  40.       line |> Seq.iteri (fun x c ->
  41.          let brush = toBrush c
  42.          graphics.FillRectangle(brush, x*32, y*32, 32, 32)
  43.       )      
  44.    )
  45.    form.ShowDialog() |> ignore
  46.  
  47. show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement