Advertisement
ptrelford

Bubbles (Android)

Aug 17th, 2013
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.08 KB | None | 0 0
  1. namespace AndroidApp
  2.  
  3. open Android.App
  4. open Android.Graphics
  5. open Android.Widget
  6.  
  7. [<Activity(Label = "Bubbles", MainLauncher = true)>]
  8. type ArtActivity() =
  9.     inherit Activity()
  10.  
  11.     override this.OnCreate(bundle) =
  12.         base.OnCreate(bundle)
  13.  
  14.         let layout = new LinearLayout(this)
  15.         layout.Orientation <- Orientation.Horizontal
  16.  
  17.         let width, height = 1280, 720
  18.         let bm = Bitmap.CreateBitmap(width,height,Bitmap.Config.Argb8888)
  19.         let view = new ImageView(this)
  20.         view.SetImageBitmap(bm)
  21.         layout.AddView(view)        
  22.         this.SetContentView(layout)
  23.  
  24.         let colors = [|Color.Red; Color.Green; Color.Blue; Color.Yellow|]
  25.         let canvas = new Canvas(bm)
  26.         let rand = System.Random()
  27.         for i = 1 to 400 do
  28.             let paint = new Paint(Color=colors.[rand.Next(colors.Length)])
  29.             paint.Alpha <- rand.Next(255)
  30.             let x, y = rand.Next(width), rand.Next(height)
  31.             let r = 10 + rand.Next(40)          
  32.             canvas.DrawCircle(float32 x,float32 y,float32 r,paint)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement