本文整理汇总了C#中Android.Graphics.Canvas.DrawColor方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.DrawColor方法的具体用法?C# Canvas.DrawColor怎么用?C# Canvas.DrawColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.DrawColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetColorWithOpacity
public static Color GetColorWithOpacity(this Activity activity, int normalColor, int opacityColor)
{
var bitmap = Bitmap.CreateBitmap(1, 1, Bitmap.Config.Argb8888); //make a 1-pixel Bitmap
var canvas = new Canvas(bitmap);
canvas.DrawColor(activity.Resources.GetColor(normalColor)); //color we want to apply filter to
canvas.DrawColor(activity.Resources.GetColor(opacityColor), PorterDuff.Mode.SrcAtop); //apply filter
var index = bitmap.GetPixel(0, 0);
return Color.Argb(index, index, index, index);
}
示例2: drawPorcentajeOnCanvas
private void drawPorcentajeOnCanvas(Canvas canvas)
{
base.OnDraw (canvas);
canvas.Save ();
canvas.DrawColor(Android.Graphics.Color.White);
//Obtenemos el centro de nuesto canvas
float x = this.MeasuredWidth / 2;
float y = this.MeasuredHeight / 2;
//Obtenemos el radio R1
//Obtenemos el radio R2
float R1 = 0;
float R2 = 0;
//if (canvas.Width < canvas.Height) {
if (this.MeasuredWidth < this.MeasuredHeight) {
R1 = x;//Obtenemos el radio R1
R2 = x-(x*por_rango/100);
} else {
R1 = y ;//Obtenemos el radio R1
R2 = y-(y *por_rango/100);//Obtenemos el radio R2 que dejamos un 20% de margen
}
//Dibujamos el fondo de nuestro grafico que va ir creciendo de acuerdo al porcentaje descargado
RectF rectF2 = new RectF(x-R1, y-R1,x+R1, y+R1);
mPaintFondo.Color= Android.Graphics.Color.Rgb(19,184,213);
int grados = 0;
grados = 360 * porcentaje / 100;
canvas.DrawArc(rectF2, 270, grados, true, mPaintFondo);
//Fondo superior de nuestro texto
mPaintSuperior.Color= Android.Graphics.Color.Rgb(50,58,69);
canvas.DrawCircle(x,y , R2, mPaintSuperior);
//Texto que nos indica el procentaje descargado
mPaintTexto.SetTypeface (mFace);
mPaintTexto.Color = Color.White;
//Obtenemos el 30 % de radio de nuestro circulo de fondo, el cual sera el tamaño de letra utilzar;
float MYTEXTSIZE = R2 *30/100;
// Get the screen's density scale
float scale = Application.Context.Resources.DisplayMetrics.Density;
//Convert the dps to pixels, based on density scale
int textSizePx = (int) (MYTEXTSIZE * scale + 0.5f);
mPaintTexto.TextSize = textSizePx;
//Obtenemos la posicion para centrar adecuadamente nuesto texto
int xPos = (this.MeasuredWidth / 2);
int yPos = (int) ((this.MeasuredHeight / 2) - ((mPaintTexto.Descent() + mPaintTexto.Ascent()) / 2)) ;
string Texto_Porcentaje =porcentaje.ToString();
canvas.DrawText (Texto_Porcentaje+" %", xPos,yPos, mPaintTexto);
canvas.Restore();
}
示例3: Draw
public override void Draw (Canvas canvas)
{
var bounds = Bounds;
if (alpha != 255) {
paint.Alpha = 255;
if (SecondBitmap != null) {
if (shader1 == null)
shader1 = new BitmapShader (FirstBitmap, Shader.TileMode.Clamp, Shader.TileMode.Clamp);
shader1.SetLocalMatrix (matrix);
paint.SetShader (shader1);
canvas.DrawRect (bounds, paint);
} else
canvas.DrawColor (defaultColor.ToAndroidColor());
}
if (alpha != 0) {
paint.Alpha = alpha;
if (FirstBitmap != null) {
if (shader2 == null)
shader2 = new BitmapShader (SecondBitmap, Shader.TileMode.Clamp, Shader.TileMode.Clamp);
shader2.SetLocalMatrix (matrix);
paint.SetShader (shader2);
canvas.DrawRect (bounds, paint);
} else
canvas.DrawColor (defaultColor.ToAndroidColor());
}
}
示例4: OnDraw
protected override void OnDraw(Canvas canvas) {
base.OnDraw (canvas);
if (mBlurredView != null) {
if (prepare()) {
// If the background of the blurred view is a color drawable, we use it to clear
// the blurring canvas, which ensures that edges of the child views are blurred
// as well; otherwise we clear the blurring canvas with a transparent color.
if (mBlurredView.Background != null && mBlurredView.Background is ColorDrawable){
mBitmapToBlur.EraseColor(((ColorDrawable) mBlurredView.Background).Color);
}else {
mBitmapToBlur.EraseColor(Color.Transparent);
}
mBlurredView.Draw(mBlurringCanvas);
blur();
canvas.Save();
canvas.Translate(mBlurredView.GetX() - GetX(), mBlurredView.GetY() - GetY());
canvas.Scale(mDownsampleFactor, mDownsampleFactor);
canvas.DrawBitmap(mBlurredBitmap, 0, 0, null);
canvas.Restore();
}
canvas.DrawColor(mOverlayColor);
}
}
示例5: DrawMask
public void DrawMask(View target, Canvas maskCanvas, Color maskColor, Point position, int radius, Animator animator)
{
// draw solid background
maskCanvas.DrawColor(maskColor);
// erase focus area
maskCanvas.DrawCircle(position.X, position.Y, radius, eraserPaint);
}
示例6: OnDraw
protected override void OnDraw(Canvas canvas)
{
canvas.DrawColor (Color.White);
mPaint.SetTypeface (null);
canvas.DrawText ("Default", 10, 100, mPaint);
mPaint.SetTypeface (mFace);
canvas.DrawText ("Custom", 10, 200, mPaint);
}
示例7: ShowPath
private 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();
}
示例8: CreateImage
private File CreateImage()
{
using (var b = Bitmap.CreateBitmap(100, 100, Bitmap.Config.Argb8888))
using (Canvas c = new Canvas(b))
{
var color = Color.Argb(255, rnd.Next(256), rnd.Next(256), rnd.Next(256));
c.DrawColor(color);
return SaveBitmap(b);
}
}
示例9: DrawMask
public void DrawMask(View target, Canvas maskCanvas, Color maskColor, Point position, int radius, Animator animator)
{
var valueAnimator = animator as ValueAnimator;
var bounce = valueAnimator != null ? (float)valueAnimator.AnimatedValue : target.Alpha;
// draw solid background
maskCanvas.DrawColor(maskColor);
// erase focus area
maskCanvas.DrawCircle(position.X, position.Y, radius * bouncy.GetInterpolation(bounce), eraserPaint);
}
示例10: OnDraw
protected override void OnDraw(Canvas canvas)
{
Paint paint = mPaint;
canvas.DrawColor(Color.Argb(255, 204, 204, 204));
canvas.Translate(20, 20);
paint.AntiAlias = true;
ShowPath(canvas, 0, 0, Path.FillType.Winding, paint);
ShowPath(canvas, 160, 0, Path.FillType.EvenOdd, paint);
ShowPath(canvas, 0, 160, Path.FillType.InverseWinding, paint);
ShowPath(canvas, 160, 160, Path.FillType.InverseEvenOdd, paint);
}
示例11: OnDraw
protected override void OnDraw(Canvas canvas)
{
canvas.DrawColor (Color.White);
Paint p = new Paint ();
float y = 10;
p.Color = Color.Red;
canvas.DrawBitmap (mBitmap, 10, y, p);
y += mBitmap.Height + 10;
canvas.DrawBitmap (mBitmap2, 10, y, p);
y += mBitmap2.Height + 10;
p.SetShader (mShader);
canvas.DrawBitmap (mBitmap3, 10, y, p);
}
示例12: OnDraw
protected override void OnDraw (Canvas canvas)
{
canvas.DrawColor (Color.White);
canvas.Translate (10, 10);
canvas.SaveLayerAlpha (0, 0, 200, 200, 0x88, SaveFlags.All);
mPaint.Color = Color.Red;
canvas.DrawCircle (75, 75, 75, mPaint);
mPaint.Color = Color.Blue;
canvas.DrawCircle (125, 125, 75, mPaint);
canvas.Restore ();
}
示例13: DoDraw
private void DoDraw(Canvas canvas, double stepFactor)
{
double width = canvas.GetWidth();
double height = canvas.GetHeight();
double x = width/2;
double y = height/2;
x += xOrientation * stepFactor;
y += yOrientation * stepFactor;
// Set background color
canvas.DrawColor(Color.BLUE);
var paint = new Paint();
paint.TextAlign =(Paint.Align.CENTER);
// Draw a circle
paint.Color =(Color.ParseColor("#ffd700"));
canvas.DrawCircle((float) x, (float) y, 30, paint);
}
示例14: SampleView
//private int Width;
//private int Height;
public SampleView(Context context)
: base(context)
{
Log.Debug(tag, "Start view");
Focusable = true;
//foreach (var item in DataClass.Drawables)
// item.Visible = false;
mPaint = new Paint();
mPaint.AntiAlias = true;
IWindowManager wm = context.GetSystemService(WindowService).JavaCast<IWindowManager>();
Display dsp = wm.DefaultDisplay;
Width = dsp.Width;
Height = dsp.Height;
mBmp = Bitmap.CreateBitmap(Width, Height, Bitmap.Config.Argb8888);
canvasBitmap = new Canvas(mBmp);
canvasBitmap.DrawColor(Color.Black);
Log.Debug(tag, String.Format("Client W:{0}, H:{1}", Width, Height));
}
示例15: GetCharData
public Size GetCharData(char c, out UInt32[] cdata)
{
float height=(fontsize * 1.25f);
int ih = (int)height;
if ((height - ih) > 0) ih++;
float width = paint.MeasureText(c.ToString());
int iw = (int)width;
if ((width - iw) > 0) iw++;
//canvas.Restore();
Bitmap bitmap = Bitmap.CreateBitmap(iw, ih, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(bitmap);
canvas.DrawColor(Android.Graphics.Color.Transparent);
canvas.DrawText(c.ToString(), 0, fontsize, paint);
cdata = new UInt32[iw * ih];
int[] data = new int[iw * ih];
bitmap.GetPixels(data, 0, iw, 0, 0, iw, ih);
for (int i = 0; i < data.Length; i++)
{
cdata[i] = (uint)data[i];
}
return new Size(iw, ih);
}