void CreateBitmapData (string str, out byte[] bitmapData, out int width, out int height) { Paint paint = new Paint (); paint.TextSize = 128; paint.TextAlign = Paint.Align.Left; paint.SetTypeface (Typeface.Default); width = height = 256; float textWidth = paint.MeasureText (str); using (Bitmap bitmap = Bitmap.CreateBitmap (width, height, Bitmap.Config.Argb8888)) { Canvas canvas = new Canvas (bitmap); paint.Color = str != " " ? Color.White : Color.LightGray; canvas.DrawRect (new Rect (0, 0, width, height), paint); paint.Color = Color.Black; canvas.DrawText (str, (256 - textWidth) / 2f, (256 - paint.Descent () - paint.Ascent ()) / 2f, paint); bitmapData = new byte [width * height * 4]; Java.Nio.ByteBuffer buffer = Java.Nio.ByteBuffer.Allocate (bitmapData.Length); bitmap.CopyPixelsToBuffer (buffer); buffer.Rewind (); buffer.Get (bitmapData, 0, bitmapData.Length); } }
void Initialize () { _basePaint = new Paint (); _basePaint.Color = Color.Black; _basePaint.AntiAlias = true; _basePaint.SetStyle (Paint.Style.Fill); _gridPaint = new Paint (); _gridPaint.SetStyle (Paint.Style.Stroke); _gridPaint.Color = Color.ParseColor (RSColors.RS_LIGHT_GRAY); _circlesPaint = new Paint (); _circlesPaint.Color = Color.ParseColor (RSColors.PURPLE_4); _circlesPaint.SetStyle (Paint.Style.Fill); _circlesPaint.AntiAlias = true; _dataLabelPaint = new Paint (); _dataLabelPaint.Color = Color.ParseColor (RSColors.GREEN_4); _dataLabelPaint.TextSize = PixelUtil.GetPixelFromDP (dataLabelSize, _context.Resources); _dataLabelPaint.SetStyle (Paint.Style.Stroke); _dataLabelPaint.AntiAlias = true; _dataLabelPaint.SetTypeface (Typeface.DefaultBold); _dataLabelPaint.TextAlign = Paint.Align.Center; _dataLabelBgPaint = new Paint (); _dataLabelBgPaint.Color = Color.White; _dataLabelBgPaint.SetStyle (Paint.Style.Fill); _xLabelPaint = new Paint (); _xLabelPaint.Color = Color.Black; _xLabelPaint.SetStyle (Paint.Style.Stroke); _xLabelPaint.AntiAlias = true; _xLabelPaint.TextAlign = Paint.Align.Center; _xLabelPaint.TextSize = PixelUtil.GetPixelFromDP (xLabelSize, _context.Resources); }
public DrawingImageView(Context context, Fragment fragment): base(context) { mPaint = new Paint(); mPaint.AntiAlias = true; mPaint.Dither = true; mPaint.Color = Color.Yellow; mPaint.SetStyle (Paint.Style.Stroke); mPaint.StrokeJoin = Paint.Join.Round; mPaint.StrokeCap = Paint.Cap.Round; mPaint.StrokeWidth = 10; cPaint = new Paint (); cPaint.Color = Color.Yellow; cPaint.StrokeJoin = Paint.Join.Round; cPaint.StrokeCap = Paint.Cap.Round; cPaint.SetTypeface(Typeface.Default); cPaint.TextSize = 40; mPath = new Android.Graphics.Path(); mBitmapPaint = new Paint(); mBitmapPaint.Color = Color.Yellow; DrawingStatus = DrawingType.None; _fragment = fragment; }
public override Android.Graphics.Drawables.Drawable GetBackgroundForPage (int row, int column) { Point pt = new Point (column, row); Drawable drawable; if (!mBackgrounds.ContainsKey(pt)) { // the key wasn't found in Dictionary var bm = Bitmap.CreateBitmap(200, 200, Bitmap.Config.Argb8888); var c = new Canvas(bm); var p = new Paint(); // Clear previous image. c.DrawRect(0, 0, 200, 200, p); p.AntiAlias = true; p.SetTypeface(Typeface.Default); p.TextSize = 64; p.Color = Color.LightGray; p.TextAlign = Paint.Align.Center; c.DrawText(column + "-" + row, 100, 100, p); drawable = new BitmapDrawable(owner.Resources, bm); mBackgrounds.Add(pt, drawable); } else { // the key was found drawable = mBackgrounds[pt]; } return drawable; }
public Task <Bitmap> LoadImageAsync( ImageSource imagesource, Context context, CancellationToken cancelationToken = default(CancellationToken)) { Bitmap image = null; var fontsource = imagesource as FontImageSource; if (fontsource != null) { using var paint = new Paint { TextSize = TypedValue.ApplyDimension(ComplexUnitType.Dip, (float)fontsource.Size, context.Resources.DisplayMetrics), Color = (fontsource.Color != null ? fontsource.Color : Colors.White).ToAndroid(), TextAlign = Paint.Align.Left, AntiAlias = true, }; paint.SetTypeface(fontsource.FontFamily.ToTypeface()); var width = (int)(paint.MeasureText(fontsource.Glyph) + .5f); var baseline = (int)(-paint.Ascent() + .5f); var height = (int)(baseline + paint.Descent() + .5f); image = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888); using var canvas = new Canvas(image); canvas.DrawText(fontsource.Glyph, 0, baseline, paint); } return(Task.FromResult(image)); }
private static void ApplyCustomTypeFace(Paint paint, Typeface tf, Android.Graphics.Color color) { int oldStyle; Typeface old = paint.Typeface; if (old == null) { oldStyle = 0; } else { oldStyle = (int)old.Style; } int fake = oldStyle & ~(int)tf.Style; if ((fake & (int)TypefaceStyle.Bold) != 0) { paint.FakeBoldText = true; } if ((fake & (int)TypefaceStyle.Italic) != 0) { paint.TextSkewX = -0.25f; } paint.SetARGB(color.A, color.R, color.G, color.B); paint.SetTypeface(tf); }
void InitStepCountPaint() { stepcountPaint = new Paint(); //stepcountPaint.Color = Color.White; stepcountPaint.SetARGB(255, 50, 151, 218); stepcountPaint.SetTypeface(Typeface.Create(Typeface.SansSerif, TypefaceStyle.Normal)); stepcountPaint.AntiAlias = true; stepcountPaint.TextSize = owner.Resources.GetDimension(Resource.Dimension.StepCountTextSize); }
private static void ApplyCustomTypeface(Paint paint, Typeface tf, TypefaceStyle style, int size) { if (style == TypefaceStyle.Italic) paint.TextSkewX = -0.25f; if(size > 0) paint.TextSize = size; paint.SetTypeface (tf); }
public static void SetFont(this AG.Paint paint, FontData font) { paint.SetTypeface(font.Typeface); // textsize is in pixel, fontsize in points // point = pix * 72 / screen.dpi => pix = point * dpi / 72 paint.TextSize = (float)(font.Size * Xdpi / 72f) * FontFactor; #if __ANDROID_21__ paint.LetterSpacing = .... #endif }
private void ApplyCustomTypeFace(Paint paint, Typeface tf) { paint.FakeBoldText = false; paint.TextSkewX = 0f; paint.SetTypeface(tf); if (_rotate) paint.ClearShadowLayer(); if (_iconSizeRatio > 0) paint.TextSize = (paint.TextSize * _iconSizeRatio); else if (_iconSizePx > 0) paint.TextSize = _iconSizePx; if (_iconColor < Int32.MaxValue) paint.Color = new Color(_iconColor); paint.Flags = paint.Flags | PaintFlags.SubpixelText; }
/// <Docs>The Canvas to which the View is rendered.</Docs> /// <summary> /// Draw the specified canvas. /// </summary> /// <param name="canvas">Canvas.</param> public override void Draw(Android.Graphics.Canvas canvas) { base.Draw(canvas); var paintForAngle = new Paint { Color = (Android.Graphics.Color.White), TextSize = 37f }; paintForAngle.SetStyle(Paint.Style.Stroke); paintForAngle.SetTypeface(Typeface.CreateFromAsset(Forms.Context.Assets, "Fonts/fontawesome.ttf")); canvas.DrawText('\uf078'.ToString(), (float)(canvas.ClipBounds.CenterX() * 1.65), (float)(canvas.ClipBounds.CenterY() * 1.15), paintForAngle); #region Disposing paintForAngle.Dispose(); canvas.Dispose(); #endregion }
internal void DrawText(string text, Paint p, Typeface font, float size, Rectangle rect, ReoGridHorAlign halign, ReoGridVerAlign valign) { p.SetTypeface(font); p.TextSize = size; var measuredRect = new Rect(); p.GetTextBounds(text, 0, text.Length, measuredRect); float x = rect.Left, y = rect.Top; switch (halign) { case ReoGridHorAlign.General: case ReoGridHorAlign.Left: x = rect.Left; break; case ReoGridHorAlign.Center: x = rect.Left + (rect.Width - measuredRect.Width()) / 2; break; case ReoGridHorAlign.Right: x = rect.Right - measuredRect.Width(); break; } switch (valign) { case ReoGridVerAlign.Top: y = rect.Top + measuredRect.Height(); break; case ReoGridVerAlign.Middle: y = rect.Bottom - (rect.Height - measuredRect.Height()) / 2; break; case ReoGridVerAlign.General: case ReoGridVerAlign.Bottom: y = rect.Bottom; break; } this.canvas.DrawText(text, x, y, p); }
private static void apply(Paint paint, Typeface tf) { TypefaceStyle oldStyle; var old = paint.Typeface; if (old == null) { oldStyle = 0; } else { oldStyle = old.Style; } var fake = oldStyle & ~tf.Style; if ((fake & TypefaceStyle.Bold) == TypefaceStyle.Bold) { paint.FakeBoldText = true; } if ((fake & TypefaceStyle.Italic) == TypefaceStyle.Italic) { paint.TextSkewX = -0.25f; } paint.SetTypeface(tf); paint.Flags = paint.Flags | PaintFlags.SubpixelText; }
public static float AdjustTextToSize(string text, SizeF box, float edgeInset, Context context) { SizeF constrainSize = new SizeF (box.Width - edgeInset, 9999); float toReturn = 0f; Paint paint = new Paint (PaintFlags.AntiAlias); paint.TextSize = 16f; paint.SetTypeface (Typeface.Default); float height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context); if (height > box.Height - edgeInset) { do { height -= 0.5f; paint.TextSize = height; height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context); } while (height > box.Height - edgeInset); toReturn = paint.TextSize; } else if (height < box.Height - edgeInset) { do { height += 0.5f; paint.TextSize = height; height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context); } while (height < box.Height - edgeInset); toReturn = paint.TextSize; } else { toReturn = paint.TextSize; }//end if else return toReturn; }
private void Apply(Paint paint) { paint.SetTypeface(_typeface); }
private void Init() { this.Focusable = true; if (list == null) { list = new List<Sentence>(); var sen = new Sentence(0, "��ʱû��֪ͨ����"); list.Add(sen); } // �Ǹ������� mPaint = new Paint { AntiAlias = true, TextSize = 16, Color = Color.Black }; mPaint.SetTypeface(Typeface.Serif); // �������� ��ǰ��� mPathPaint = new Paint { AntiAlias = true, Color = Color.Red, TextSize = 18 }; mPathPaint.SetTypeface(Typeface.SansSerif); }
protected override void OnDraw(Android.Graphics.Canvas canvas) { if (mixerValue == null) // don't do anything if we're not connected to a mixervalue return; if (bmp == null) { bmp = BitmapFactory.DecodeResource (Resources, Resource.Drawable.Fader_Knob); Bitmap scaled = Bitmap.CreateScaledBitmap (bmp, 25, 55, true); bmp.Recycle(); bmp = scaled; } int margin = 60; float radius = 4; int center = (Width / 2) + 5; int minY1 = margin - (bmp.Height / 2); int maxY1 = Height - margin - (bmp.Height / 2); rangeY = maxY1 - minY1; float factor = (float)mixerValue.GetValue() / (float)maxValue; bitmapX1 = center - bmp.Width / 2; bitmapY1 = maxY1 - (int)(factor * (float)rangeY); base.OnDraw (canvas); var paint = new Paint (); paint.Color = Color.White; paint.TextAlign = Paint.Align.Center; paint.TextSize = (float)12.0; paint.SetTypeface(Typeface.DefaultBold); if (channel_name != null) canvas.DrawText (channel_name, center - 5, 14, paint); // align with pan control int levelX1 = center - (bmp.Width / 2) - 2; int levelX2 = center + (bmp.Width / 2); paint.TextSize = (float)10.0; paint.TextAlign = Paint.Align.Right; foreach (var level in faderLevels) { float factorLevel = (float)level.Key / (float)maxValue; int levelY = maxY1 - (int)(factorLevel * (float)rangeY) + (bmp.Height / 2); canvas.DrawRect (levelX1, levelY - 1, levelX2, levelY, paint); canvas.DrawText (level.Value, levelX1 - 4, levelY + 3, paint); } paint.Color = Color.DarkGray; RectF rect = new RectF (center - 2, margin, center + 2, Height - margin); canvas.DrawRoundRect(rect, radius, radius, paint); paint.Color = Color.Black; rect = new RectF (center - 1, margin + 1, center + 1, Height - margin - 1); canvas.DrawRoundRect(rect, radius, radius, paint); bitmapX2 = bitmapX1 + bmp.Width; bitmapY2 = bitmapY1 + bmp.Height; if (isActive) { paint.Alpha = 255; } else { paint.Alpha = 180; } canvas.DrawBitmap (bmp, bitmapX1, bitmapY1, paint); //bmp.Recycle (); }
void Apply(Paint paint) { paint.SetTypeface(Font.ToTypeface()); float value = Font.ToScaledPixel(); paint.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Sp, value, TextView.Resources.DisplayMetrics); }
private Paint CreateTextPaint(Color defaultInteractiveColor, Typeface typeface) { Paint paint = new Paint (); paint.Color = defaultInteractiveColor; paint.SetTypeface (typeface); paint.AntiAlias = true; return paint; }
Paint BuildDroidPaint(Font font, Color c, Paint.Style style) { var paint = new Paint (); paint.Color = Android.Graphics.Color.Argb (c.Alpha, c.Red, c.Green, c.Blue); paint.AntiAlias = true; paint.SetStyle (style); // Fix for font issue on android. if(null != font) { paint.TextSize = _font.Size; Typeface tf; if(font.FontFamily == "Monospace") { tf = Typeface.Create (Typeface.Monospace, GetDroidTypefaceStyle(font)); } else if(font.FontFamily == "SystemFont") { tf = Typeface.Default; if(font.IsBold) { tf = Typeface.DefaultBold; } } else { tf = Typeface.Create(font.FontFamily, GetDroidTypefaceStyle(font)); } paint.SetTypeface(tf); } return paint; }
public CompassView(Context context, Android.Util.IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { _paint = new Paint(); _paint.SetStyle(Paint.Style.Fill); _paint.AntiAlias = true; _paint.TextSize = (float)DIRECTION_TEXT_HEIGHT; _paint.SetTypeface(Typeface.Create("sans-serif-thin", TypefaceStyle.Normal)); _tickPaint = new Paint(); _tickPaint.SetStyle(Paint.Style.Stroke); _tickPaint.StrokeWidth = (float)TICK_WIDTH; _tickPaint.AntiAlias = true; _tickPaint.Color = Color.White; _placePaint = new TextPaint(); _placePaint.SetStyle(Paint.Style.Fill); _placePaint.AntiAlias = true; _placePaint.Color = Color.White; _placePaint.TextSize = (float)PLACE_TEXT_HEIGHT; _placePaint.SetTypeface(Typeface.Create("sans-serif-light", TypefaceStyle.Normal)); _path = new Path(); _textBounds = new Rect(); _allBounds = new List<Rect>(); _distanceFormat = NumberFormat.GetNumberInstance(Locale.Default); _distanceFormat.MinimumFractionDigits = 0; _distanceFormat.MaximumFractionDigits = 1; _placeBitmap = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.place_mark); _animatedHeading = Double.NaN; _directions = context.Resources.GetStringArray(Resource.Array.direction_abbreviations); _animator = new ValueAnimator(); setupAnimator(); }
static void ApplyFontToPaint(Font f, Paint p) { var fi = GetFontInfo (f); p.SetTypeface (fi.Typeface); p.TextSize = f.Size; if (fi.FontMetrics == null) { fi.FontMetrics = new AndroidFontMetrics (p); } }
private void ApplyCustomTypeFace(Paint paint, Typeface typeface) { paint.FakeBoldText = false; paint.TextSkewX = 0f; paint.SetTypeface(typeface); if (_rotate) { paint.ClearShadowLayer(); } if (_iconSizeRatio > 0) { paint.TextSize = paint.TextSize*_iconSizeRatio; } else if (_iconSizePx > 0) { paint.TextSize = _iconSizePx; } if (_iconColor < int.MaxValue) { paint.Color = _iconColor; } }
/// <summary> /// Creates and returns the text parameters for the given callout text area. /// </summary> /// <returns> /// A Pair<UIFont, SizeF> containing the font and text size. /// </returns> /// <param name='textRect'> /// The current text area of the callout. /// </param> /// <param name='text'> /// The text for which to calculate and create the parameters. /// </param> public static float GetTextParamsForCallout(RectangleF textRect, string text, Context context) { SizeF constrainSize = new SizeF (textRect.Width, 9999); Paint paint = new Paint (PaintFlags.AntiAlias); paint.TextSize = 18f; paint.SetTypeface (Typeface.Default); float height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context); float minHeight = textRect.Height - 2f; if (height > minHeight) { do { height -= 1f; paint.TextSize = height; height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context); } while (height > textRect.Height); } else if (height < minHeight) { do { height += 1f; paint.TextSize = height; height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context); } while (height < minHeight); }//end if else return paint.TextSize; }
void Initialize() { if (robotoCondensed == null) LoadTypefaces (Context.Assets); prefs = new PreferenceManager (Context); digitPaint = new Paint { AntiAlias = true, Color = Color.White, TextAlign = Paint.Align.Center, TextScaleX = .85f }; unitPaint = new Paint { AntiAlias = true, Color = Color.Rgb (0xc0, 0xba, 0xb0), TextAlign = Paint.Align.Center, }; descPaint = new Paint { AntiAlias = true, Color = Color.Rgb (0xdb, 0xd7, 0xcf), TextAlign = Paint.Align.Center, }; unitPaint.SetTypeface (robotoCondensed); descPaint.SetTypeface (robotoCondensed); SetBackgroundResource (Resource.Drawable.circle); }
public Size MeasureString(string text, Font font) { using (var p = new Paint(this.paint)) using (var bounds = new Rect()) using (var fm = p.GetFontMetrics()) { p.TextSize = font.Size; p.SetTypeface(font.FontFamily.Typeface); p.SetStyle(Paint.Style.Stroke); p.GetTextBounds(text, 0, text.Length, bounds); var width = bounds.Width(); var height = -fm.Top + fm.Bottom; return new SizeF(width, height).ToSize(); } }
private void InitializeImages() { if(_pressedImage != null) { _pressedImage.Recycle(); _pressedImage.Dispose(); } if(_unpressedImage != null) { _unpressedImage.Recycle(); _unpressedImage.Dispose(); } _unpressedImage = Bitmap.CreateBitmap(Width, Settings.IsSquared ? Width : Height, Bitmap.Config.Argb8888); _pressedImage = Bitmap.CreateBitmap(Width, Settings.IsSquared ? Width : Height, Bitmap.Config.Argb8888); Canvas unpressedCanvas = new Canvas(_unpressedImage); Canvas pressedCanvas = new Canvas(_pressedImage); Settings.SetTextSize(ComplexUnitType.Px, Settings.TextSize == 0f ? Height * Settings.TextSizeRatio : Settings.TextSize); Settings.StrokeBorderWidth = Height * Settings.StrokeBorderWidthRatio; Settings.StrokeTextWidth = Height * Settings.StrokeTextWidthRatio; // Background fill paint Paint fillBackPaint = new Paint(); fillBackPaint.Color = Settings.FillColor; fillBackPaint.AntiAlias = true; // Background stroke paint Paint strokeBackPaint = new Paint(); strokeBackPaint.Color = Settings.StrokeColor; strokeBackPaint.SetStyle(Paint.Style.Stroke); strokeBackPaint.StrokeWidth = Settings.StrokeBorderWidth; strokeBackPaint.AntiAlias = true; // Text paint Paint textPaint = new Paint(); textPaint.Color = Settings.IsTextStroked ? Settings.FillColor : Settings.StrokeColor; textPaint.TextAlign = Paint.Align.Center; textPaint.TextSize = Settings.TextSize; textPaint.SetTypeface(Settings.Typeface); textPaint.AntiAlias = true; // Text stroke paint Paint strokePaint = new Paint(); strokePaint.Color = Settings.StrokeColor; strokePaint.TextAlign = Paint.Align.Center; strokePaint.TextSize = Settings.TextSize; strokePaint.SetTypeface(Settings.Typeface); strokePaint.SetStyle(Paint.Style.Stroke); strokePaint.StrokeWidth = Settings.StrokeTextWidth; strokePaint.AntiAlias = true; // Background bounds Rect local = new Rect(); this.GetLocalVisibleRect(local); RectF bounds = new RectF(local); bounds.Top += Settings.StrokeBorderWidth/2; bounds.Left += Settings.StrokeBorderWidth/2; bounds.Right -= Settings.StrokeBorderWidth/2; bounds.Bottom -= Settings.StrokeBorderWidth/2; while(bounds.Top > Height) { bounds.Top -= Height; } while(bounds.Bottom > Height) { bounds.Bottom -= Height; } while(bounds.Left > Width) { bounds.Left -= Width; } while(bounds.Right > Width) { bounds.Right -= Width; } // Text location Rect r = new Rect(); strokePaint.GetTextBounds(Text, 0, Text.Length, r); while(r.Width() + Settings.StrokeTextWidth >= bounds.Width()) { Settings.SetTextSize(ComplexUnitType.Px, Settings.TextSize-1); textPaint.TextSize = Settings.TextSize; strokePaint.TextSize = Settings.TextSize; strokePaint.GetTextBounds(Text, 0, Text.Length, r); } float x=0, y=0; switch (Settings.Gravity) { case GravityFlags.Top: y = PaddingTop + r.Height()/2; break; case GravityFlags.Bottom: y = Height - r.Height()/2 - PaddingBottom; break; default: y = Height / 2f + r.Height() / 2f - r.Bottom; break; } switch (Settings.Gravity) { case GravityFlags.Left: x = PaddingLeft + r.Width()/2; break; case GravityFlags.Right: x = Width - r.Width()/2 - PaddingRight; break; default: x = Width/2; break; } // Draw unpressed DrawBackground(unpressedCanvas, bounds, fillBackPaint, strokeBackPaint); if(Settings.IsTextStroked) unpressedCanvas.DrawText(Text, x, y, strokePaint); unpressedCanvas.DrawText(Text, x, y, textPaint); // Change colors fillBackPaint.Color = Settings.StrokeColor; strokeBackPaint.Color = Settings.FillColor; strokePaint.Color = Settings.FillColor; textPaint.Color = Settings.IsTextStroked ? Settings.StrokeColor : Settings.FillColor; // Draw pressed DrawBackground(pressedCanvas, bounds, fillBackPaint, strokeBackPaint); if(Settings.IsTextStroked) pressedCanvas.DrawText(Text, x, y, strokePaint); pressedCanvas.DrawText(Text, x, y, textPaint); // Set images for states StateListDrawable states = new StateListDrawable(); states.AddState(new int[] {Android.Resource.Attribute.StatePressed}, new BitmapDrawable(_pressedImage)); states.AddState(new int[] {Android.Resource.Attribute.StateFocused}, new BitmapDrawable(_pressedImage)); states.AddState(new int[] {Android.Resource.Attribute.StateSelected}, new BitmapDrawable(_pressedImage)); states.AddState(new int[] { }, new BitmapDrawable(_unpressedImage)); SetBackgroundDrawable(states); strokePaint.Dispose(); textPaint.Dispose(); strokeBackPaint.Dispose(); fillBackPaint.Dispose(); unpressedCanvas.Dispose(); pressedCanvas.Dispose(); }
private void ApplyCustomTypeFace(Paint paint, Typeface tf) { paint.FakeBoldText = false; paint.TextSkewX = 0f; paint.SetTypeface(tf); if (rotate) paint.ClearShadowLayer(); if (iconSizeRatio > 0) paint.TextSize = paint.TextSize * iconSizeRatio; else if (iconSizePx > 0) paint.TextSize = iconSizePx; if (iconColor < int.MaxValue) paint.Color = new Color(iconColor); }
private void Initialize() { textPaint = new Paint () { Color = Color.Rgb (0xf3, 0xf3, 0xf3), AntiAlias = true, TextAlign = Paint.Align.Center, TextSize = DefaultFontSize }; textPaint.SetTypeface (Typeface.DefaultBold); lightPaint = new Paint () { Color = Color.Rgb (0xff, 0xff, 0xff), AntiAlias = true, TextAlign = Paint.Align.Center, TextSize = DefaultFontSize }; lightPaint.SetTypeface (Typeface.DefaultBold); darkPaint = new Paint () { Color = Color.Argb (0x30, 0, 0, 0), AntiAlias = true, TextAlign = Paint.Align.Center, TextSize = DefaultFontSize }; darkPaint.SetTypeface (Typeface.DefaultBold); }
public override ImageReference GetBackground (int row, int col) { var pt = new Point (row, col); ImageReference imgRef = null; if(mBackgrounds.ContainsKey(pt)) imgRef = mBackgrounds [pt]; if (imgRef == null) { var bm = Bitmap.CreateBitmap (200, 200, Bitmap.Config.Argb8888); var c = new Canvas (bm); var p = new Paint (); c.DrawRect (0, 0, 200, 200, p); p.AntiAlias = true; p.SetTypeface (Typeface.Default); p.TextSize = 64; p.Color = Color.LightGray; c.DrawText (col + "-" + row, 20, 100, p); imgRef = ImageReference.ForBitmap (bm); mBackgrounds.Add (pt, imgRef); } return imgRef; }