当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.Canvas类代码示例

本文整理汇总了C#中Android.Graphics.Canvas的典型用法代码示例。如果您正苦于以下问题:C# Canvas类的具体用法?C# Canvas怎么用?C# Canvas使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Canvas类属于Android.Graphics命名空间,在下文中一共展示了Canvas类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCroppedBitmap

        static Bitmap GetCroppedBitmap (Bitmap bmp, int radius)
        {
            Bitmap sbmp;
            if (bmp.Width != radius || bmp.Height != radius)
                sbmp = Bitmap.CreateScaledBitmap (bmp, radius, radius, false);
            else
                sbmp = bmp;
            var output = Bitmap.CreateBitmap (sbmp.Width,
                             sbmp.Height, Bitmap.Config.Argb8888);
            var canvas = new Canvas (output);

            var paint = new Paint ();
            var rect = new Rect (0, 0, sbmp.Width, sbmp.Height);

            paint.AntiAlias = true;
            paint.FilterBitmap = true;
            paint.Dither = true;
            canvas.DrawARGB (0, 0, 0, 0);
            paint.Color = Color.ParseColor ("#BAB399");
            canvas.DrawCircle (sbmp.Width / 2 + 0.7f, sbmp.Height / 2 + 0.7f,
                sbmp.Width / 2 + 0.1f, paint);
            paint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.SrcIn));
            canvas.DrawBitmap (sbmp, rect, rect, paint);

            return output;
        }
开发者ID:vgvassilev,项目名称:couchbase-connect-14,代码行数:26,代码来源:RoundedImageView.cs

示例2: draw

			public void draw(Canvas canvas) {
			
			pathA.getPointOnLine(parameter, coordsA);
			pathB.getPointOnLine(parameter, coordsB);
			if (rounded) insetPointsForRoundCaps();
			canvas.DrawLine(coordsA[0], coordsA[1], coordsB[0], coordsB[1], linePaint);
			}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:7,代码来源:DrawerArrowDrawable.cs

示例3: Draw

 public override void Draw(Canvas canvas)
 {
     foreach (Chaser chaser in _chasers)
     {
         chaser.Draw(canvas);
     }
 }
开发者ID:Verdungo,项目名称:testRep,代码行数:7,代码来源:DrawingView.cs

示例4: OnDraw

		protected override void OnDraw (Canvas canvas)
		{
			if (this.currentPath == null || this.currentPath.IsEmpty)
				return;

			canvas.DrawPath (this.currentPath, this.currentPaint);
		}
开发者ID:ronrat,项目名称:SignaturePad,代码行数:7,代码来源:SignatureCanvasView.cs

示例5: Draw

        public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
        {
            try
            {
                if (!feature.RenderedGeometry.ContainsKey(style)) feature.RenderedGeometry[style] = ToAndroidBitmap(feature.Geometry);
                var bitmap = (AndroidGraphics.Bitmap)feature.RenderedGeometry[style];
                
                var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                dest = new BoundingBox(
                    dest.MinX,
                    dest.MinY,
                    dest.MaxX,
                    dest.MaxY);

                var destination = RoundToPixel(dest);
                using (var paint = new Paint())
                {
                    canvas.DrawBitmap(bitmap, new Rect(0, 0, bitmap.Width, bitmap.Height), destination, paint);
                }

                DrawOutline(canvas, style, destination);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:28,代码来源:RasterRenderer.cs

示例6: OnDraw

		protected override void OnDraw (Canvas canvas)
		{
			
			drawCanvas = canvas;
			canvas.DrawBitmap(canvasBitmap, 0, 0, canvasPaint);
			canvas.DrawPath(drawPath, drawPaint);
		}
开发者ID:CrossGeeks,项目名称:Xamarin.Samples,代码行数:7,代码来源:NativeDrawView.cs

示例7: 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();
		}
开发者ID:DiLRandI,项目名称:Xamarin.android,代码行数:60,代码来源:ProgressCircleView.cs

示例8: Draw

 public new void Draw(Canvas canvas, Paint paint)
 {
     int viewWidth = mProgressBar.Width;
     int viewHeight = mProgressBar.Height;
     canvas.DrawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2 + mShadowRadius), mShadowPaint);
     canvas.DrawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2), paint);
 }
开发者ID:devxiaruwei,项目名称:MaterialProgressbar,代码行数:7,代码来源:OvalShadow.cs

示例9: Draw

 public override void Draw(Canvas canvas)
 {
     foreach (CirclePaint item in _touches)
     {
         item.Draw(canvas);
     }
 }
开发者ID:Verdungo,项目名称:testRep,代码行数:7,代码来源:DrawingView.cs

示例10: DrawStopwatch

        public void DrawStopwatch(Canvas canvas)
        {
            canvas.Save();
            canvas.Translate(Width / 2F, Height / 2F);
            
            var tickMarks = new Path();
            tickMarks.AddCircle(0, 0, 90, Path.Direction.Cw);

            var scale = Math.Min(Width, Height) / 2F / 120;
            canvas.Scale(scale, scale);

            var paint = new Paint
            {
                StrokeCap = Paint.Cap.Square,
                Color = new Color(240, 240, 240)
            };

            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeWidth = 3;
            paint.SetPathEffect(MinuteDashEffect);
            canvas.DrawPath(tickMarks, paint);

            paint.Color = new Color(240, 240, 240);
            paint.StrokeWidth = 4;
            paint.SetPathEffect(FifthMinuteDashEffect);
            canvas.DrawPath(tickMarks, paint);
        }
开发者ID:adolfo7x,项目名称:Play.Stopwatch,代码行数:27,代码来源:StopwatchView.cs

示例11: GetBackgroundForPage

			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;
			}
开发者ID:xamarin,项目名称:monodroid-samples,代码行数:28,代码来源:GridExampleActivity.cs

示例12: DispatchDraw

		protected override void DispatchDraw (Canvas canvas)
		{
			base.DispatchDraw (canvas);
			if (!firstTime)
				return;
			
			for(int i = 0; i< tabs.TabCount; i++)
			{
				var tab = tabs.GetTabAt (i);
				var page = tabbedPage.Children [tab.Position];

				if (page is TabPage) {

					var tPage = (TabPage)page;

					SetTab (tab, (tabs.SelectedTabPosition == tab.Position) ? tPage.SelectedIcon.File : tPage.Icon.File);

				} else 
				{
					SetTab (tab, page.Icon.File);

				}

				if (!tabbedPage.ShowTitles) 
				{
					tab.SetText (string.Empty);
				}

			}
			firstTime = false;


		}
开发者ID:patrickpetropoulos,项目名称:Xamarin.Samples,代码行数:33,代码来源:CustomTabbedPageRenderer.cs

示例13: transformCanvas

 public void transformCanvas(Canvas canvas, float percentOpen)
 {
     mtrans.transformCanvas(canvas, percentOpen);
     float f = minterp.GetInterpolation(percentOpen);
     canvas.Scale((mopenedX - mclosedX) * f + mclosedX,
             (mopenedY - mclosedY) * f + mclosedY, mpx, mpy);
 }
开发者ID:skywolf888,项目名称:SlidingMenu.Net,代码行数:7,代码来源:CanvasTransformerBuilder.cs

示例14: OnDraw

		protected override void OnDraw(Canvas canvas)
		{
			base.OnDraw(canvas);
			_buttonBackgroundPaint.Color = _backgroundColor;

			float diameter = _radius * 2;
			float uWidth = PaddingLeft == 0 && PaddingRight == 0 ? diameter : Width - PaddingLeft - PaddingRight;
			float uHeight = PaddingBottom == 0 && PaddingTop == 0 ? diameter : Height - PaddingTop - PaddingBottom;
			float cx = uWidth / 2;
			float cy = uHeight / 2;
			float radius = Math.Min(uWidth - DipToPixels(2), uHeight - DipToPixels(2)) / 2;

			if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
			{
				SetLayerType(LayerType.Software, null);
			}
			_shadowPaint.SetShadowLayer(10, 0, 0, _shadowColor);
			canvas.DrawCircle(cx, cy, radius - 4, _shadowPaint);
			canvas.DrawCircle(cx, cy, radius, _buttonBackgroundPaint);
			
			int sidePadding = (int)(_radius * 0.25);
			int ulPadding = (int)(_radius * (0.25 + _contentScale));
			_drawableContent?.SetBounds(sidePadding, sidePadding, ulPadding, ulPadding);
			_drawableContent?.Draw(canvas);
		}
开发者ID:heith,项目名称:Xamarin.Android.FloatingActionButton,代码行数:25,代码来源:FloatingActionButton.cs

示例15: 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());
			}
		}
开发者ID:rmarinho,项目名称:xamarin-store-app,代码行数:27,代码来源:KenBurnsDrawable.cs


注:本文中的Android.Graphics.Canvas类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。