public MyAnimationView(AnimationEventsActivity context)
     : base(context)
 {
     activity = context;
     density  = Context.Resources.DisplayMetrics.Density;
     ball     = CreateBall(25, 25);
 }
            public MyAnimationView(Context context)
                : base(context)
            {
                density = Context.Resources.DisplayMetrics.Density;

                ball = CreateBall(25, 25);
            }
            public MyAnimationView(Context context)
                : base(context)
            {
                density = Context.Resources.DisplayMetrics.Density;

                ball = CreateBall(25, 25);
            }
            public MyAnimationView(Context context, SeekBar seekBar)
                : base(context)
            {
                density = Context.Resources.DisplayMetrics.Density;

                this.seekBar = seekBar;
                ball         = AddBall(10 * density, 0);
            }
Exemplo n.º 5
0
 protected override void OnDraw(Canvas canvas)
 {
     for (int i = 0; i < balls.Count; ++i)
     {
         ShapeHolder shapeHolder = balls[i];
         canvas.Save();
         canvas.Translate(shapeHolder.X, shapeHolder.Y);
         shapeHolder.Shape.Draw(canvas);
         canvas.Restore();
     }
 }
Exemplo n.º 6
0
            private ShapeHolder CreateBall(float x, float y)
            {
                var circle = new OvalShape();

                circle.Resize(BallSize * density, BallSize * density);
                var drawable    = new ShapeDrawable(circle);
                var shapeHolder = new ShapeHolder(drawable);

                shapeHolder.X = x;
                shapeHolder.Y = y - (BallSize / 2f);
                return(shapeHolder);
            }
            private ShapeHolder CreateBall(float x, float y)
            {
                var rnd    = new Random();
                var circle = new OvalShape();

                circle.Resize(BallSize * density, BallSize * density);
                var drawable    = new ShapeDrawable(circle);
                var shapeHolder = new ShapeHolder(drawable);

                shapeHolder.X = x - 25f;
                shapeHolder.Y = y - 25f;
                var red       = 100 + rnd.Next(155);
                var green     = 100 + rnd.Next(155);
                var blue      = 100 + rnd.Next(155);
                var color     = new Color(red, green, blue);
                var darkColor = new Color(red / 4, green / 4, blue);
                var paint     = drawable.Paint;
                var gradient  = new RadialGradient(37.5f, 12.5f, 50f, color, darkColor, Shader.TileMode.Clamp);

                paint.SetShader(gradient);
                shapeHolder.Paint = paint;
                return(shapeHolder);
            }
            internal virtual ShapeHolder AddBall(float x, float y)
            {
                var rnd    = new Random();
                var circle = new OvalShape();

                circle.Resize(BallSize * density, BallSize * density);
                var drawable    = new ShapeDrawable(circle);
                var shapeHolder = new ShapeHolder(drawable);

                shapeHolder.X = x - 25f;
                shapeHolder.Y = y - 25f;
                var            red       = 100 + rnd.Next(155);
                var            green     = 100 + rnd.Next(155);
                var            blue      = 100 + rnd.Next(155);
                var            color     = new Color(red, green, blue);
                var            darkColor = new Color(red / 4, green / 4, blue);
                Paint          paint     = drawable.Paint; //new Paint(Paint.ANTI_ALIAS_FLAG);
                RadialGradient gradient  = new RadialGradient(37.5f, 12.5f, 50f, color, darkColor, Shader.TileMode.Clamp);

                paint.SetShader(gradient);
                shapeHolder.Paint = paint;
                balls.Add(shapeHolder);
                return(shapeHolder);
            }
            private void AddBall(float x, float y)
            {
                var rnd = new Random();

                var circle = new OvalShape();
                circle.Resize(BallSize * density, BallSize * density);
                var drawable = new ShapeDrawable(circle);
                var shapeHolder = new ShapeHolder(drawable);
                shapeHolder.X = x;
                shapeHolder.Y = y - (BallSize / 2f);
                var red = 100 + rnd.Next(155);
                var green = 100 + rnd.Next(155);
                var blue = 100 + rnd.Next(155);
                var color = new Color(red, green, blue);
                var darkColor = new Color(red / 4, green / 4, blue);
                var paint = drawable.Paint;
                var gradient = new RadialGradient(37.5f, 12.5f, 50f, color, darkColor, Shader.TileMode.Clamp);
                paint.SetShader(gradient);
                shapeHolder.Paint = paint;
                balls.Add(shapeHolder);
            }
Exemplo n.º 10
0
 public BallXYHolder(ShapeHolder ball)
 {
     Ball = ball;
 }