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); } }
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); }
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); } }
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); }
public PathEffects (Context context) : base (context) { mPaint = new Paint (Paint.ANTI_ALIAS_FLAG); mPaint.setStyle (Paint.Style.STROKE); mPaint.setStrokeWidth (6); mPath = makeFollowPath (); mEffects = new PathEffect[6]; mColors = new int[] { Color.BLACK, Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.BLACK }; }
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); }
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 (); }
///** // * Instantiates a new circular seek bar. // * // * @param context // * the context // * @param attrs // * the attrs // * @param defStyle // * the def style // */ //public CircularSeekBar(Context context, AttributeSet attrs, int defStyle) { // //super(context, attrs, defStyle); // mContext = context; // //initDrawable(); //} ///** // * Instantiates a new circular seek bar. // * // * @param context // * the context // * @param attrs // * the attrs // */ //public CircularSeekBar(Context context, AttributeSet attrs) { // //super(context, attrs); // mContext = context; // //initDrawable(); //} /** * Instantiates a new circular seek bar. * * @param context * the context */ public CircularSeekBar(Context context) { //super(context); mContext = context; circleColor = new Paint(); innerColor = new Paint(); circleRing = new Paint(); circleColor.setColor(Color.parseColor("#ff33b5e5")); // Set default // progress // color to holo // blue. innerColor.setColor(Color.BLACK); // Set default background color to // black circleRing.setColor(Color.GRAY);// Set default background color to Gray circleColor.setAntiAlias(true); innerColor.setAntiAlias(true); circleRing.setAntiAlias(true); circleColor.setStrokeWidth(5); innerColor.setStrokeWidth(5); circleRing.setStrokeWidth(5); circleColor.setStyle(Paint.Style.FILL); //initDrawable(); }
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; } } }
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); }