Inheritance: java.lang.Object, android.os.Parcelable
Ejemplo n.º 1
0
		static void test_alphagradients (Canvas canvas)
		{
			canvas.translate (20, 10);

			RectF r = new RectF (10, 10, 410, 30);
			Paint p = new Paint (), p2 = new Paint ();
			p2.setStyle (Paint.Style.STROKE);

			using (Shader shader = setgrad (r, 0xFF00FF00, 0x0000FF00))
				p.setShader (shader);
			canvas.drawRect (r, p);
			canvas.drawRect (r, p2);

			r.offset (0, r.height () + 4);
			using (Shader shader = setgrad(r, 0xFF00FF00, 0x00000000))
				p.setShader (shader);
			canvas.drawRect (r, p);
			canvas.drawRect (r, p2);

			r.offset (0, r.height () + 4);
			using (Shader shader = setgrad(r, 0xFF00FF00, 0x00FF0000))
				p.setShader (shader);
			canvas.drawRect (r, p);
			canvas.drawRect (r, p2);
		}
Ejemplo n.º 2
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (unchecked((int)0xFFDDDDDD));

			Paint paint = new Paint ();
			paint.setAntiAlias (true);
			paint.setStyle (Paint.Style.STROKE);
			paint.setStrokeWidth (3);
			paint.setStyle (Paint.Style.FILL);

			RectF r = new RectF ();
			float t, x, y;

			t = GetAnimScalar (25, 500);

			canvas.translate (320, 240);

			for (int i = 0; i < 35; i++) {
				paint.setColor (unchecked((int)0xFFF00FF0 - i * 0x04000000));
				double step = Math.PI / (55 - i);
				double angle = t * step;
				x = (20 + i * 5) * (float)Math.Sin (angle);
				y = (20 + i * 5) * (float)Math.Cos (angle);
				r.set (x, y, x + 10, y + 10);
				canvas.drawRect (r, paint);
			}
		}
Ejemplo n.º 3
0
		protected override void onDraw (Canvas canvas)
		{

			Console.WriteLine ("DRAW: {0} {1}", canvas.getWidth (), canvas.getHeight ());

			RectF r = new RectF (0, 0, canvas.getWidth (), canvas.getHeight ());
			Paint paint = new Paint ();

			using (Shader shader = make_grad (canvas.getWidth(), canvas.getHeight()))
				paint.setShader (shader);
			canvas.drawRect (r, paint);
		}
Ejemplo n.º 4
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (unchecked((int)0xFFDDDDDD));

			Paint paint = new Paint ();
			paint.setAntiAlias (true);
			paint.setStyle (Paint.Style.STROKE);
			paint.setStrokeWidth (3);
			paint.setStyle (Paint.Style.FILL);

			RectF r = new RectF (10, 10, 110, 110);

			for (int i = 0; i < 256; ++i) {
				canvas.translate (1, 1);
				paint.setColor ((int)(0xFF000000 + i * 0x00010000));
				canvas.drawRect (r, paint);
			}
		}
Ejemplo n.º 5
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			RectF bounds = new RectF ();
			mPath.computeBounds (bounds, false);
			canvas.translate (10 - bounds.left, 10 - bounds.top);

			makeEffects (mEffects, mPhase);
			mPhase += 1;

			for (int i = 0; i < mEffects.Length; i++) {
				mPaint.setPathEffect (mEffects [i]);
				mPaint.setColor (mColors [i]);
				canvas.drawPath (mPath, mPaint);
				canvas.translate (0, 28);
			}
		}
Ejemplo n.º 6
0
		public Arcs (Context context)
			: base (context)
		{
			mPaints = new Paint[4];
			mUseCenters = new bool[4];
			mOvals = new RectF[4];

			mPaints [0] = new Paint ();
			mPaints [0].setAntiAlias (true);
			mPaints [0].setStyle (Paint.Style.FILL);
			mPaints [0].setColor (unchecked((int)0x88FF0000));
			mUseCenters [0] = false;

			mPaints [1] = new Paint (mPaints [0]);
			mPaints [1].setColor (unchecked((int)0x8800FF00));
			mUseCenters [1] = true;

			mPaints [2] = new Paint (mPaints [0]);
			mPaints [2].setStyle (Paint.Style.STROKE);
			mPaints [2].setStrokeWidth (4);
			mPaints [2].setColor (unchecked((int)0x880000FF));
			mUseCenters [2] = false;

			mPaints [3] = new Paint (mPaints [2]);
			mPaints [3].setColor (unchecked((int)0x88888888));
			mUseCenters [3] = true;

			mBigOval = new RectF (40, 10, 280, 250);

			mOvals [0] = new RectF (10, 270, 70, 330);
			mOvals [1] = new RectF (90, 270, 150, 330);
			mOvals [2] = new RectF (170, 270, 230, 330);
			mOvals [3] = new RectF (250, 270, 310, 330);

			mFramePaint = new Paint ();
			mFramePaint.setAntiAlias (true);
			mFramePaint.setStyle (Paint.Style.STROKE);
			mFramePaint.setStrokeWidth (0);

			// AddTimer (50);
		}
Ejemplo n.º 7
0
		void drawArcs (Canvas canvas, RectF oval, bool useCenter, Paint paint)
		{
			canvas.drawRect (oval, mFramePaint);
			canvas.drawArc (oval, mStart, mSweep, useCenter, paint);
		}
Ejemplo n.º 8
0
		static Shader MakeSweep (RectF r, GradData data, Shader.TileMode tile)
		{
			return new SweepGradient (
				r.centerX (), r.centerX (), data.Colors, data.Pos);
		}
Ejemplo n.º 9
0
		static Shader MakeRadial (RectF r, GradData data, Shader.TileMode tile)
		{
			return new RadialGradient (
				r.centerX (), r.centerY (), r.centerX (), data.Colors, data.Pos, tile);
		}
Ejemplo n.º 10
0
		static Shader MakeLinear (RectF r, GradData data, Shader.TileMode tile)
		{
			return new LinearGradient (
				r.left, r.top, r.right, r.bottom, data.Colors, data.Pos, tile);
		}
Ejemplo n.º 11
0
		static Shader setgrad (RectF r, uint c0, uint c1)
		{
			int[] colors = { unchecked((int)c0), unchecked((int)c1) };
			return new LinearGradient (
				r.left, r.top, r.right, r.top, colors, null, Shader.TileMode.CLAMP);
		}
Ejemplo n.º 12
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (unchecked((int)0xFFDDDDDD));

			test_alphagradients (canvas);

			RectF r = new RectF (0, 0, 100, 100);

			Paint paint = new Paint ();
			paint.setDither (true);

			canvas.save ();
			canvas.translate (20, 100);

			Shader.TileMode[] modes = {
				Shader.TileMode.CLAMP, Shader.TileMode.MIRROR, Shader.TileMode.CLAMP
			};

			foreach (Shader.TileMode tile in modes) {
				canvas.save ();
				foreach (GradData data in Grads) {
					canvas.save ();
					foreach (GradMaker maker in GradMakers) {
						using (Shader shader = maker(r, data, tile))
							paint.setShader (shader);
						canvas.drawRect (r, paint);
						canvas.translate (0, 120);
					}
					canvas.restore ();
					canvas.translate (120, 0);
				}
				canvas.translate (Grads.Length * 120, 0);
			}

			canvas.restore ();
			canvas.translate (0, 370);
		}