public Bitmap GetBitmapMarker(Context mContext, int resourceId, string text) { Resources resources = mContext.Resources; float scale = resources.DisplayMetrics.Density; Bitmap bitmap = BitmapFactory.DecodeResource(resources, resourceId); Bitmap.Config bitmapConfig = bitmap.GetConfig(); // set default bitmap config if none if (bitmapConfig == null) bitmapConfig = Bitmap.Config.Argb8888; bitmap = bitmap.Copy(bitmapConfig, true); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(PaintFlags.AntiAlias); paint.Color = global::Android.Graphics.Color.Black; paint.TextSize = ((int)(14 * scale)); paint.SetShadowLayer(1f, 0f, 1f, global::Android.Graphics.Color.White); // draw text to the Canvas center Rect bounds = new Rect(); paint.GetTextBounds(text, 0, text.Length, bounds); int x = (bitmap.Width - bounds.Width()) / 2; int y = (bitmap.Height + bounds.Height()) / 2 - 20; canvas.DrawText(text, x, y, paint); return bitmap; }
public TextDrawable(String text, Context ctx) { _text = text; if (_iconFont == null) _iconFont = Typeface.CreateFromAsset(ctx.Assets, "fontawesome-webfont.ttf"); _paint = new Paint {Color = (Color.White), TextSize = 22f, AntiAlias = true}; //_paint.SetTypeface(_iconFont); _paint.SetShadowLayer(6f, 0, 0, Color.Black); _paint.SetStyle(Paint.Style.Fill); _paint.TextAlign = Paint.Align.Left; }
public CreateAnimationDrawer(Context c, BrushItem brush, Canvas canvas, Bitmap myBmp, bool tooAdd = false, int cell = 1, string DrawerState = "brush_selection", Path pathToUse = null) : base(c) { myBitmap = myBmp; myCanvas = canvas; DrawerStateInternal = DrawerState; addOnly = tooAdd; status = 0; myPath = new Path(); myPaint = new Paint(PaintFlags.Dither); myPaint.AntiAlias = true; myPaint.Dither = true; myPaint.SetStyle(Paint.Style.Stroke); myPaint.StrokeJoin = Paint.Join.Round; myPaint.StrokeWidth = brush.Thickness; myPaint.StrokeCap = Paint.Cap.Round; myPaint.SetARGB(colorUtil.a, colorUtil.r, colorUtil.g, colorUtil.b); if (brush.BrushType == AnimationTypesBrushType.Spray) myPaint.SetShadowLayer(brush.Thickness, 0, 0, ImageHelper.convWZColorToColor(brush.BrushColor)); if (DrawerState == "brush_selection") { if (pathToUse != null) { myBoundsPaint = new Paint(); myBoundsPaint = new Paint(PaintFlags.Dither); myBoundsPaint.AntiAlias = true; myBoundsPaint.Dither = true; myBoundsPaint.SetStyle(Paint.Style.Stroke); myBoundsPaint.StrokeJoin = Paint.Join.Round; myBoundsPaint.StrokeWidth = 10f; myBoundsPaint.StrokeCap = Paint.Cap.Round; myBoundsPaint.SetARGB(255, 0, 0, 0); myBoundsPaint.SetPathEffect(new DashPathEffect(new float[] { 10f, 20f }, 0)); myPath = pathToUse; AnimationUtil.theCanvas.DrawPath(myPath, myPaint); AnimationUtil.theCanvas.DrawPath(myPath, myPaint); myBoundsRect = new RectF(); myPath.ComputeBounds(myBoundsRect, true); AnimationUtil.theCanvas.DrawRect(myBoundsRect, myBoundsPaint); } } }
private void Init(Color fabColor) { SetWillNotDraw(false); SetLayerType(LayerType.Software, null); _buttonPaint = new Paint(PaintFlags.AntiAlias) {Color = fabColor}; _buttonPaint.SetStyle(Paint.Style.Fill); _buttonPaint.SetShadowLayer(10.0f, 0.0f, 3.5f, Color.Argb(100, 0, 0, 0)); _drawablePaint = new Paint(PaintFlags.AntiAlias); Invalidate(); var windowManager = Context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>(); var display = windowManager.DefaultDisplay; var size = new Point(); display.GetSize(size); _screenHeight = size.Y; }
public override void Draw(Canvas canvas) { base.Draw(canvas); var paint = new Android.Graphics.Paint() { Dither = true, StrokeWidth = 4, AntiAlias = true, Color = Android.Graphics.Color.Gray }; paint.SetShadowLayer(20f, 0f, 0f, Android.Graphics.Color.Black); paint.SetStyle(Paint.Style.Stroke); var rect = new Android.Graphics.RectF(0, 0, Width, Height); canvas.DrawRoundRect(rect, Control.Radius, Control.Radius, paint); }
private void Init(Color fabColor) { //TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingActionButton); //mColor = a.getColor(R.styleable.FloatingActionButton_color, Color.WHITE); //mButtonPaint.setStyle(Paint.Style.FILL); //mButtonPaint.setColor(mColor); //float radius, dx, dy; //radius = a.getFloat(R.styleable.FloatingActionButton_shadowRadius, 10.0f); //dx = a.getFloat(R.styleable.FloatingActionButton_shadowDx, 0.0f); //dy = a.getFloat(R.styleable.FloatingActionButton_shadowDy, 3.5f); //int color = a.getInteger(R.styleable.FloatingActionButton_shadowColor, Color.argb(100, 0, 0, 0)); //mButtonPaint.setShadowLayer(radius, dx, dy, color); //Drawable drawable = a.getDrawable(R.styleable.FloatingActionButton_drawable); //if (null != drawable) //{ // mBitmap = ((BitmapDrawable)drawable).getBitmap(); //} //setWillNotDraw(false); //setLayerType(View.LAYER_TYPE_SOFTWARE, null); //WindowManager mWindowManager = (WindowManager) //context.getSystemService(Context.WINDOW_SERVICE); //Display display = mWindowManager.getDefaultDisplay(); //Point size = new Point(); //display.getSize(size); //mYHidden = size.y; SetWillNotDraw(false); SetLayerType(LayerType.Software, null); _buttonPaint = new Paint(PaintFlags.AntiAlias) {Color = fabColor}; _buttonPaint.SetStyle(Paint.Style.Fill); _buttonPaint.SetShadowLayer(10.0f, 0.0f, 3.5f, Color.Argb(100, 0, 0, 0)); _drawablePaint = new Paint(PaintFlags.AntiAlias); Invalidate(); var windowManager = Context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>(); var display = windowManager.DefaultDisplay; var size = new Point(); display.GetSize(size); _screenHeight = size.Y; }