drawColor() public method

public drawColor ( int arg0 ) : void
arg0 int
return void
Ejemplo n.º 1
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.º 2
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.GRAY);

			canvas.save ();
			canvas.translate (80, 5);
			drawOriginalRects (canvas, 0xFF);
			canvas.restore ();

			mPaint.setStyle (Paint.Style.FILL);

			canvas.save ();
			canvas.translate (0, 140);
			drawRgn (canvas, Color.RED, "Union", Region.Op.UNION);
			canvas.restore ();

			canvas.save ();
			canvas.translate (0, 280);
			drawRgn (canvas, Color.BLUE, "Xor", Region.Op.XOR);
			canvas.restore ();

			canvas.save ();
			canvas.translate (160, 140);
			drawRgn (canvas, Color.GREEN, "Difference", Region.Op.DIFFERENCE);
			canvas.restore ();

			canvas.save ();
			canvas.translate (160, 280);
			drawRgn (canvas, Color.WHITE, "Intersect", Region.Op.INTERSECT);
			canvas.restore ();
		}
Ejemplo n.º 3
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (unchecked((int)0xFFCCCCCC));

			canvas.concat (mMatrix);
			canvas.drawBitmapMesh (mBitmap, WIDTH, HEIGHT, mVerts, 0, null, 0, null);
		}
Ejemplo n.º 4
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			canvas.save ();
			canvas.translate (10, 10);
			// translate (1 point)
			doDraw (canvas, new float[] { 0, 0 }, new float[] { 5, 5 });
			canvas.restore ();

			canvas.save ();
			canvas.translate (160, 10);
			// rotate/uniform-scale (2 points)
			doDraw (canvas, new float[] { 32, 32, 64, 32 },
                           new float[] { 32, 32, 64, 48 });
			canvas.restore ();

			canvas.save ();
			canvas.translate (10, 110);
			// rotate/skew (3 points)
			doDraw (canvas, new float[] { 0, 0, 64, 0, 0, 64 },
                           new float[] { 0, 0, 96, 0, 24, 64 });
			canvas.restore ();

			canvas.save ();
			canvas.translate (160, 110);
			// perspective (4 points)
			doDraw (canvas, new float[] { 0, 0, 64, 0, 64, 64, 0, 64 },
                           new float[] { 0, 0, 96, 0, 64, 96, 0, 64 });
			canvas.restore ();
		}
Ejemplo n.º 5
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			canvas.translate (10, 10);

			canvas.save ();
			for (int i = 0; i < N; i++) {
				setSrcR (i);
				drawSrcR (canvas, i);
				canvas.translate (mSrcR.width () + 15, 0);
			}
			canvas.restore ();

			canvas.translate (0, 100);
			for (int j = 0; j < sFits.Length; j++) {
				canvas.save ();
				for (int i = 0; i < N; i++) {
					drawFit (canvas, i, sFits [j]);
					canvas.translate (mDstR.width () + 8, 0);
				}
				canvas.drawText (sFitLabels [j], 0, HEIGHT * 2 / 3, mLabelPaint);
				canvas.restore ();
				canvas.translate (0, 80);
			}
		}
Ejemplo n.º 6
0
		protected override void onDraw (Canvas canvas)
		{
			Paint paint = mPaint;
			float x = 20;
			float y = 20;

			canvas.drawColor (Color.WHITE);

			paint.setColorFilter (null);
			canvas.drawBitmap (mBitmap, x, y, paint);

			ColorMatrix cm = new ColorMatrix ();

			mAngle += 2;
			if (mAngle > 180) {
				mAngle = 0;
			}

			//convert our animated angle [-180...180] to a contrast value of [-1..1]
			float contrast = mAngle / 180.0f;

			setContrast (cm, contrast);
			paint.setColorFilter (new ColorMatrixColorFilter (cm));
			canvas.drawBitmap (mBitmap, x + mBitmap.getWidth () + 10, y, paint);

			setContrastScaleOnly (cm, contrast);
			paint.setColorFilter (new ColorMatrixColorFilter (cm));
			canvas.drawBitmap (mBitmap, x, y + mBitmap.getHeight () + 10, paint);

			setContrastTranslateOnly (cm, contrast);
			paint.setColorFilter (new ColorMatrixColorFilter (cm));
			canvas.drawBitmap (mBitmap, x, y + 2 * (mBitmap.getHeight () + 10), paint);
		}
Ejemplo n.º 7
0
		void showPath (Canvas canvas, int x, int y, Path.FillType ft, Paint paint)
		{
			canvas.save ();
			canvas.translate (x, y);
			canvas.clipRect (0, 0, 120, 120);
			canvas.drawColor (Color.WHITE);
			mPath.setFillType (ft);
			canvas.drawPath (mPath, paint);
			canvas.restore ();
		}
Ejemplo n.º 8
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			mDrawable.setBounds (mRect);

			float r = 16;

			canvas.save ();
			canvas.translate (10, 10);
			mDrawable.setGradientType (GradientDrawable.LINEAR_GRADIENT);
			setCornerRadii (mDrawable, r, r, 0, 0);
			mDrawable.draw (canvas);
			canvas.restore ();

			canvas.save ();
			canvas.translate (10 + mRect.width () + 10, 10);
			mDrawable.setGradientType (GradientDrawable.RADIAL_GRADIENT);
			setCornerRadii (mDrawable, 0, 0, r, r);
			mDrawable.draw (canvas);
			canvas.restore ();

			canvas.translate (0, mRect.height () + 10);

			canvas.save ();
			canvas.translate (10, 10);
			mDrawable.setGradientType (GradientDrawable.SWEEP_GRADIENT);
			setCornerRadii (mDrawable, 0, r, r, 0);
			mDrawable.draw (canvas);
			canvas.restore ();

			canvas.save ();
			canvas.translate (10 + mRect.width () + 10, 10);
			mDrawable.setGradientType (GradientDrawable.LINEAR_GRADIENT);
			setCornerRadii (mDrawable, r, 0, 0, r);
			mDrawable.draw (canvas);
			canvas.restore ();

			canvas.translate (0, mRect.height () + 10);

			canvas.save ();
			canvas.translate (10, 10);
			mDrawable.setGradientType (GradientDrawable.RADIAL_GRADIENT);
			setCornerRadii (mDrawable, r, 0, r, 0);
			mDrawable.draw (canvas);
			canvas.restore ();

			canvas.save ();
			canvas.translate (10 + mRect.width () + 10, 10);
			mDrawable.setGradientType (GradientDrawable.SWEEP_GRADIENT);
			setCornerRadii (mDrawable, 0, r, 0, r);
			mDrawable.draw (canvas);
			canvas.restore ();
		}
Ejemplo n.º 9
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (unchecked((int)0xFFCCCCCC));
			canvas.save ();
			canvas.concat (mMatrix);

			canvas.drawVertices (Canvas.VertexMode.TRIANGLE_FAN, 10, mVerts, 0,
                                mTexs, 0, null, 0, null, 0, 0, mPaint);

			canvas.translate (0, 240);
			canvas.drawVertices (Canvas.VertexMode.TRIANGLE_FAN, 10, mVerts, 0,
                                mTexs, 0, null, 0, mIndices, 0, 6, mPaint);

			canvas.restore ();
		}
Ejemplo n.º 10
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			canvas.translate (10, 10);

			canvas.saveLayerAlpha (0, 0, 200, 200, 0x88, LAYER_FLAGS);

			mPaint.setColor (Color.RED);
			canvas.drawCircle (75, 75, 75, mPaint);
			mPaint.setColor (Color.BLUE);
			canvas.drawCircle (125, 125, 75, mPaint);

			canvas.restore ();
		}
Ejemplo n.º 11
0
		protected override void onDraw (Canvas canvas)
		{
			Paint paint = new Paint (Paint.ANTI_ALIAS_FLAG);

			canvas.drawColor (unchecked((int)0xFFCCCCCC));

			canvas.translate (20, 20);

			paint.setAntiAlias (true);

			showPath (canvas, 0, 0, Path.FillType.WINDING, paint);
			showPath (canvas, 160, 0, Path.FillType.EVEN_ODD, paint);
			showPath (canvas, 0, 160, Path.FillType.INVERSE_WINDING, paint);
			showPath (canvas, 160, 160, Path.FillType.INVERSE_EVEN_ODD, paint);
		}
Ejemplo n.º 12
0
		void drawScene (Canvas canvas)
		{
			canvas.clipRect (0, 0, 100, 100);

			canvas.drawColor (Color.WHITE);

			mPaint.setColor (Color.RED);
			canvas.drawLine (0, 0, 100, 100, mPaint);

			mPaint.setColor (Color.GREEN);
			canvas.drawCircle (30, 70, 30, mPaint);

			mPaint.setColor (Color.BLUE);
			canvas.drawText ("Clipping", 100, 30, mPaint);
		}
Ejemplo n.º 13
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			Paint p = new Paint ();
			float y = 10;

			p.setColor (Color.RED);
			canvas.drawBitmap (mBitmap, 10, y, p);
			y += mBitmap.getHeight () + 10;
			canvas.drawBitmap (mBitmap2, 10, y, p);
			y += mBitmap2.getHeight () + 10;
			p.setShader (mShader);
			canvas.drawBitmap (mBitmap3, 10, y, p);
		}
Ejemplo n.º 14
0
		protected override void onDraw (Canvas canvas)
		{
			Paint paint = new Paint ();

			canvas.translate (10, 10);

			canvas.drawColor (Color.WHITE);

			paint.setColor (Color.RED);
			paint.setStrokeWidth (0);
			canvas.drawLines (mPts, paint);

			paint.setColor (Color.BLUE);
			paint.setStrokeWidth (3);
			canvas.drawPoints (mPts, paint);
		}
Ejemplo n.º 15
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.GRAY);

			canvas.save ();
			canvas.translate (10, 10);
			drawScene (canvas);
			canvas.restore ();

			canvas.save ();
			canvas.translate (160, 10);
			canvas.clipRect (10, 10, 90, 90);
			canvas.clipRect (30, 30, 70, 70, Region.Op.DIFFERENCE);
			drawScene (canvas);
			canvas.restore ();

			canvas.save ();
			canvas.translate (10, 160);
			mPath.reset ();
			canvas.clipPath (mPath); // makes the clip empty
			mPath.addCircle (50, 50, 50, Path.Direction.CCW);
			canvas.clipPath (mPath, Region.Op.REPLACE);
			drawScene (canvas);
			canvas.restore ();

			canvas.save ();
			canvas.translate (160, 160);
			canvas.clipRect (0, 0, 60, 60);
			canvas.clipRect (40, 40, 100, 100, Region.Op.UNION);
			drawScene (canvas);
			canvas.restore ();

			canvas.save ();
			canvas.translate (10, 310);
			canvas.clipRect (0, 0, 60, 60);
			canvas.clipRect (40, 40, 100, 100, Region.Op.XOR);
			drawScene (canvas);
			canvas.restore ();

			canvas.save ();
			canvas.translate (160, 310);
			canvas.clipRect (0, 0, 60, 60);
			canvas.clipRect (40, 40, 100, 100, Region.Op.REVERSE_DIFFERENCE);
			drawScene (canvas);
			canvas.restore ();
		}
Ejemplo n.º 16
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.º 17
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.º 18
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (unchecked((int)0xFFDDDDDD));

			canvas.save ();

			Paint paint = new Paint ();
			paint.setColor (Color.BLUE);

			MaskFilter mf = new BlurMaskFilter (128, BlurMaskFilter.Blur.NORMAL);
			paint.setMaskFilter (mf);
			mf.Dispose ();

			canvas.translate (200, 200);
			canvas.drawCircle (100, 100, 200, paint);

			canvas.restore ();

			paint.Dispose ();
		}
Ejemplo n.º 19
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			drawArcs (canvas, mBigOval, mUseCenters [mBigIndex], mPaints [mBigIndex]);

			for (int i = 0; i < 4; i++) {
				drawArcs (canvas, mOvals [i], mUseCenters [i], mPaints [i]);
			}

			mSweep += SWEEP_INC;
			if (mSweep > 360) {
				mSweep -= 360;
				mStart += START_INC;
				if (mStart >= 360) {
					mStart -= 360;
				}
				mBigIndex = (mBigIndex + 1) % mOvals.Length;
			}
		}
Ejemplo n.º 20
0
		protected override void onDraw(Canvas canvas)
		{
			canvas.drawColor(Color.YELLOW);
			int width = canvas.getWidth();
			int height = canvas.getHeight();

			Paint paint = new Paint();
			paint.setColor(Color.RED);
			paint.setStyle(Paint.Style.STROKE);
			paint.setStrokeWidth(10);
			canvas.drawCircle(width / 2, height / 2, height / 3, paint);

			Paint inner = new Paint();
			paint.setColor(Color.GREEN);
			paint.setStyle(Paint.Style.FILL);
			canvas.drawCircle(width / 2, height / 2, height / 3 - 10, inner);

			Paint text = new Paint();
			text.setTextSize(20);
			canvas.drawText("I am a Xobot Monkey!", width / 8, height / 8, text);
		}
Ejemplo n.º 21
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 (10);

			EmbossMaskFilter mf = new EmbossMaskFilter (new float[] { 1, 1, 1 }, 128, 16 * 2, 4);
			paint.setMaskFilter (mf);
			mf.Dispose ();

			// paint.setMaskFilter(new SkEmbossMaskFilter(fLight, SkIntToScalar(4)))->unref();
			// paint.setShader(new SkColorShader(SK_ColorBLUE))->unref();

			paint.setDither (true);

			canvas.drawCircle (50, 50, 30, paint);

			paint.Dispose ();
		}
Ejemplo n.º 22
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (unchecked((int)0xFFCCCCCC));

			canvas.translate (8, 12);
			foreach (int color in mColors) {
				ColorFilter filter;
				if (color == 0) {
					filter = null;
				} else {
					filter = new PorterDuffColorFilter (color,
                                                       mModes [mModeIndex]);
				}
				drawSample (canvas, filter);
				canvas.translate (0, 55);
			}
		}
Ejemplo n.º 23
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			Paint labelP = new Paint (Paint.ANTI_ALIAS_FLAG);
			labelP.setTextAlign (Paint.Align.CENTER);

			Paint paint = new Paint ();
			paint.setFilterBitmap (false);

			canvas.translate (15, 35);

			int x = 0;
			int y = 0;
			for (int i = 0; i < sModes.Length; i++) {
				// draw the border
				paint.setStyle (Paint.Style.STROKE);
				paint.setShader (null);
				canvas.drawRect (x - 0.5f, y - 0.5f,
						x + W + 0.5f, y + H + 0.5f, paint);

				// draw the checker-board pattern
				paint.setStyle (Paint.Style.FILL);
				paint.setShader (mBG);
				canvas.drawRect (x, y, x + W, y + H, paint);

				// draw the src/dst example into our offscreen bitmap
				int sc = canvas.saveLayer (x, y, x + W, y + H, null,
							  Canvas.MATRIX_SAVE_FLAG |
							  Canvas.CLIP_SAVE_FLAG |
							  Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
							  Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
							  Canvas.CLIP_TO_LAYER_SAVE_FLAG);
				canvas.translate (x, y);
				canvas.drawBitmap (mDstB, 0, 0, paint);
				paint.setXfermode (sModes [i]);
				canvas.drawBitmap (mSrcB, 0, 0, paint);
				paint.setXfermode (null);
				canvas.restoreToCount (sc);

				// draw the label
				canvas.drawText (sLabels [i],
						x + W / 2, y - labelP.getTextSize () / 2, labelP);

				x += W + 10;

				// wrap around when we've drawn enough for one row
				if ((i % ROW_MAX) == ROW_MAX - 1) {
					x = 0;
					y += H + 30;
				}
			}
		}
Ejemplo n.º 24
0
		void OnDraw (System.IntPtr native_canvas)
		{
			using (Canvas canvas = new Canvas(native_canvas)) {
				canvas.drawColor (Color.BLACK);

				/*
				 * Do not call Control.Invalidate() while we're drawing;
				 * Winforms would simply discard it.
				 */
				do {
					invalidate_requested = false;
					drawing = true;
					XobotActivityManager.Invoke ((window) => window.OnDraw (canvas));
					drawing = false;
				} while (invalidate_requested);
			}
		}
Ejemplo n.º 25
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);
		}