public Clipping (Context context) : base (context) { mPaint = new Paint (); mPaint.setAntiAlias (true); mPaint.setStrokeWidth (6); mPaint.setTextSize (16); mPaint.setTextAlign (Paint.Align.RIGHT); mPath = new Path (); }
static void drawIntoBitmap (Bitmap bm) { float x = bm.getWidth (); float y = bm.getHeight (); Canvas c = new Canvas (bm); Paint p = new Paint (); p.setAntiAlias (true); p.setAlpha (0x80); c.drawCircle (x / 2, y / 2, x / 2, p); p.setAlpha (0x30); p.setXfermode (new PorterDuffXfermode (PorterDuff.Mode.SRC)); p.setTextSize (60); p.setTextAlign (Paint.Align.CENTER); Paint.FontMetrics fm = p.getFontMetrics (); c.drawText ("Alpha", x / 2, (y - fm.ascent) / 2, p); }
public ColorFilters (Context context) : base (context) { mDrawable = getResources ().getDrawable (R.drawable.btn_default_normal); mDrawable.setBounds (0, 0, 150, 48); mDrawable.setDither (true); int[] resIDs = new int[] { R.drawable.btn_circle_normal, R.drawable.btn_check_off, R.drawable.btn_check_on }; mDrawables = new Drawable[resIDs.Length]; Drawable prev = mDrawable; for (int i = 0; i < resIDs.Length; i++) { mDrawables [i] = getResources ().getDrawable (resIDs [i]); mDrawables [i].setDither (true); addToTheRight (mDrawables [i], prev); prev = mDrawables [i]; } mPaint = new Paint (); mPaint.setAntiAlias (true); mPaint.setTextSize (16); mPaint.setTextAlign (Paint.Align.CENTER); mPaint2 = new Paint (mPaint); mPaint2.setAlpha (64); Paint.FontMetrics fm = mPaint.getFontMetrics (); mPaintTextOffset = (fm.descent + fm.ascent) * 0.5f; mColors = new uint[] { 0, 0xCC0000FF, 0x880000FF, 0x440000FF, 0xFFCCCCFF, 0xFF8888FF, 0xFF4444FF }; mModes = new PorterDuff.Mode[] { PorterDuff.Mode.SRC_ATOP, PorterDuff.Mode.MULTIPLY, }; mModeIndex = 0; updateTitle (); }
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); }
protected override void onDraw(Canvas canvas) { Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.RED); paint.setTextSize(30); canvas.drawText(text, 10, 60, paint); base.onDraw(canvas); }