• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Graphics.RectF类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetRoundedCornerBitmap

		// If you would like to create a circle of the image set pixels to half the width of the image.
		internal static   Bitmap GetRoundedCornerBitmap(Bitmap bitmap, int pixels)
		{
			Bitmap output = null;

			try
			{
				output = Bitmap.CreateBitmap(bitmap.Width, bitmap.Height, Bitmap.Config.Argb8888);
				Canvas canvas = new Canvas(output);

				Color color = new Color(66, 66, 66);
				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, bitmap.Width, bitmap.Height);
				RectF rectF = new RectF(rect);
				float roundPx = pixels;

				paint.AntiAlias = true;
				canvas.DrawARGB(0, 0, 0, 0);
				paint.Color = color;
				canvas.DrawRoundRect(rectF, roundPx, roundPx, paint);

				paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
				canvas.DrawBitmap(bitmap, rect, rect, paint);
			}
			catch (System.Exception err)
			{
				System.Console.WriteLine ("GetRoundedCornerBitmap Error - " + err.Message);
			}

			return output;
		}
开发者ID:suchithm,项目名称:SampleImageBitMap,代码行数:31,代码来源:ImageHelper.cs


示例2: GenerateNextTransition

		public Transition GenerateNextTransition(RectF drawableBounds, RectF viewport)
		{
			bool firstTransition = _mLastGenTrans == null;
			bool drawableBoundsChanged = true;
			bool viewportRatioChanged = true;

			RectF srcRect = null;
			RectF dstRect = null;

			if (!firstTransition)
			{
				dstRect = _mLastGenTrans.GetDestinyRect();
				drawableBoundsChanged = !drawableBounds.Equals(_mLastDrawableBounds);
				viewportRatioChanged = !MathUtils.HaveSameAspectRatio(dstRect, viewport);
			}

			if (dstRect == null || drawableBoundsChanged || viewportRatioChanged)
			{
				srcRect = GenerateRandomRect(drawableBounds, viewport);
			}
			else
			{
				/* Sets the destiny rect of the last transition as the source one
				 if the current drawable has the same dimensions as the one of
				 the last transition. */
				srcRect = dstRect;
			}
			dstRect = GenerateRandomRect(drawableBounds, viewport);

			_mLastGenTrans = new Transition(srcRect, dstRect, _mTransitionDuration,
					_mTransitionIInterpolator);
			_mLastDrawableBounds = drawableBounds;

			return _mLastGenTrans;
		}
开发者ID:Julien-Mialon,项目名称:MaterialViewPager.Xamarin,代码行数:35,代码来源:RandomTransitionGenerator.cs


示例3: Draw

        public override void Draw(Android.Graphics.Canvas canvas)
        {
            base.Draw(canvas);

            var rect = new RectF(0,0,300,300);
            switch (TheShape)
            {
                case Shape.Circle:
                    canvas.DrawOval(rect, new Paint() { Color = Color.Aqua });
                    break;
                case Shape.Square:
                    canvas.DrawRect(rect, new Paint() { Color = Color.Red });
                    break;
                case Shape.Triangle:
                    var path = new Path();
                    path.MoveTo(rect.CenterX(), 0);
                    path.LineTo(0, rect.Height());
                    path.LineTo(rect.Width(), rect.Height());
                    path.Close();

                    var paint = new Paint() {Color = Color.Magenta};
                    paint.SetStyle(Paint.Style.Fill);
                    canvas.DrawPath(path, paint);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:29,代码来源:CustomDrawShapeView.cs


示例4: Draw

        public override void Draw(Android.Graphics.Canvas canvas)
        {
            base.Draw (canvas);

            Paint mBgPaints = new Paint ();
            mBgPaints.AntiAlias = true;
            mBgPaints.SetStyle (Paint.Style.Fill);
            mBgPaints.Color = Color.Blue;
            mBgPaints.StrokeWidth = 0.5f;

            Paint tPaint = new Paint ();
            tPaint.Alpha = 0;
            canvas.DrawColor (tPaint.Color);

            RectF mOvals = new RectF (40, 40, layout.MeasuredWidth - 40, layout.MeasuredHeight - 40);

            decimal total = 0;
            foreach (SecuritiesViewModel.PieChartValue value in securitiesViewModel.DataForPieChart ()) {
                total += value.amount;
            }

            if (total == 0) {
                return;
            }

            decimal degressPerAmount = 360 / total;
            decimal currentAngle = 0;
            foreach (SecuritiesViewModel.PieChartValue value in securitiesViewModel.DataForPieChart ()) {
                canvas.DrawArc (mOvals, (float)currentAngle, (float)(degressPerAmount * value.amount), true, mBgPaints);
                currentAngle += (degressPerAmount * value.amount);
                mBgPaints.SetARGB (255, new Random ().Next (256), new Random ().Next (256), new Random ().Next (256));
            }
        }
开发者ID:sadiq81,项目名称:Pengeplan_Xamarin,代码行数:33,代码来源:PieView.cs


示例5: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            var rect = new RectF(0, 0, 300, 300);
            switch (Shape)
            {
                case Shape.Circle:
                    canvas.DrawOval(rect, new Paint() { Color = Color.CornflowerBlue });
                    break;
                case Shape.Square:
                    canvas.DrawRect(rect, new Paint() { Color = Color.Crimson });
                    break;
                case Shape.Triangle:

                    var path = new Path();
                    path.MoveTo(rect.CenterX(), rect.Top);
                    path.LineTo(rect.Left, rect.Bottom);
                    path.LineTo(rect.Right, rect.Bottom);
                    path.Close();
                    var paint = new Paint() {Color = Color.Crimson};
                    paint.Color = Color.Gold;
                    paint.SetStyle(Paint.Style.Fill);
                    canvas.DrawPath(path, paint);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:Coolerhino,项目名称:MvvmCross-Tutorials,代码行数:27,代码来源:ShapeView.cs


示例6: parse

		public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint, RectF pRect) {
			float? centerX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_X);
			float? centerY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_Y);
			float? radiusX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_X);
			float? radiusY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_Y);
			if (centerX != null && centerY != null && radiusX != null && radiusY != null) {
				pRect.Set(centerX.Value - radiusX.Value,
				          centerY.Value - radiusY.Value,
				          centerX.Value + radiusX.Value,
				          centerY.Value + radiusY.Value);

				bool fill = pSVGPaint.setFill(pSVGProperties);
				if (fill) {
					pCanvas.DrawOval(pRect, pSVGPaint.getPaint());
				}

				bool stroke = pSVGPaint.setStroke(pSVGProperties);
				if (stroke) {
					pCanvas.DrawOval(pRect, pSVGPaint.getPaint());
				}

				if(fill || stroke) {
					pSVGPaint.ensureComputedBoundsInclude(centerX.Value - radiusX.Value, centerY.Value - radiusY.Value);
					pSVGPaint.ensureComputedBoundsInclude(centerX.Value + radiusX.Value, centerY.Value + radiusY.Value);
				}
			}
		}
开发者ID:jdluzen,项目名称:xamsvg,代码行数:27,代码来源:SVGEllipseParser.cs


示例7: OnDraw

 protected override void OnDraw(Canvas canvas)
 {
     Android.Graphics.Drawable.Drawable drawable = GetDrawable();
     if (drawable is BitmapDrawable)
     {
         RectF rectF = new RectF(drawable.GetBounds());
         int restoreCount = canvas.SaveLayer(rectF, null, Canvas.AllSaveFlag);
         GetImageMatrix().MapRect(rectF);
         Paint paint = ((BitmapDrawable)drawable).GetPaint();
         paint.SetAntiAlias(true);
         paint.SetColor(unchecked((int)(0xff000000)));
         canvas.DrawARGB(0, 0, 0, 0);
         canvas.DrawRoundRect(rectF, Radius, Radius, paint);
         Xfermode restoreMode = paint.GetXfermode();
         paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
         base.OnDraw(canvas);
         // Restore paint and canvas
         paint.SetXfermode(restoreMode);
         canvas.RestoreToCount(restoreCount);
     }
     else
     {
         base.OnDraw(canvas);
     }
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:25,代码来源:RoundedImageView.cs


示例8: ToRounded

        public static Bitmap ToRounded(Bitmap source, float rad)
        {
            int size = Math.Min(source.Width, source.Height);

            int dx = (source.Width - size) / 2;
            int dy = (source.Height - size) / 2;

            Bitmap bitmap = Bitmap.CreateBitmap(size, size, Bitmap.Config.Argb8888);

            using (Canvas canvas = new Canvas(bitmap))
            using (Paint paint = new Paint())
            using (BitmapShader shader = new BitmapShader(source, Shader.TileMode.Clamp, Shader.TileMode.Clamp))
            using (Matrix matrix = new Matrix())
            {
                if (dx != 0 || dy != 0)
                {
                    // source isn't square, move viewport to centre
                    matrix.SetTranslate(-dx, -dy);
                    shader.SetLocalMatrix(matrix);
                }
                paint.SetShader(shader);
                paint.AntiAlias = true;

                RectF rectF = new RectF(0, 0, size, size);
                canvas.DrawRoundRect(rectF, rad, rad, paint);

                return bitmap;
            }
        }
开发者ID:piyushdutta,项目名称:FFImageLoading,代码行数:29,代码来源:RoundedTransformation.cs


示例9: HandleShapeDraw

		protected virtual void HandleShapeDraw (Canvas canvas)
		{
			// We need to account for offsetting the coordinates based on the padding
			var x = GetX () + Resize (this.ShapeView.Padding.Left);
			var y = GetY () + Resize (this.ShapeView.Padding.Top);

			switch (ShapeView.ShapeType) {
			case ShapeType.Box:
				HandleStandardDraw (canvas, p => {
					var rect = new RectF (x, y, x + this.Width, y + this.Height);
					if (ShapeView.CornerRadius > 0) {
						var cr = Resize (ShapeView.CornerRadius);
						canvas.DrawRoundRect (rect, cr, cr, p);
					} else {
						canvas.DrawRect (rect, p);
					}
				});
				break;
			case ShapeType.Circle:
				HandleStandardDraw (canvas, p => canvas.DrawCircle (x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p));
				break;
			case ShapeType.CircleIndicator:
				HandleStandardDraw (canvas, p => canvas.DrawCircle (x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p), drawFill: false);
				HandleStandardDraw (canvas, p => canvas.DrawArc (new RectF (x, y, x + this.Width, y + this.Height), QuarterTurnCounterClockwise, 360 * (ShapeView.IndicatorPercentage / 100), false, p), ShapeView.StrokeWidth + 3, false);
				break;
			}
		}
开发者ID:asj-it,项目名称:Xamarin-Forms-Shape,代码行数:27,代码来源:Shape.cs


示例10: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw (canvas);

            var stokewidth = TapUtil.dptodx (this.stokewidthdp);
            var progresswidth = TapUtil.dptodx (this.progresswidthdp);
            //draw border
            int center = Width / 2;
            nn_paint.SetStyle(Paint.Style.Stroke);
            nn_paint.Color=nn_outcolor;
            nn_paint.StrokeWidth = stokewidth;
            canvas.DrawCircle(center,center, nn_radius-stokewidth, nn_paint);

            //draw remainingsection of progress
            nn_paint.SetStyle (Paint.Style.Fill);
            nn_paint.Color=nn_progressremainingcolor;
            //RectF position is relative toparent
            canvas.DrawCircle(center,center, nn_radius-stokewidth*2, nn_paint);

            //draw progress
            nn_paint.SetStyle (Paint.Style.Stroke);
            nn_paint.Color=nn_progresscolor;
            nn_paint.StrokeWidth = progresswidthdp*2;
            //RectF position is relative toparent
            RectF oval = new RectF (0+(stokewidth*2)+Convert.ToSingle(progresswidthdp*1.5),0+(stokewidth*2)+Convert.ToSingle(progresswidthdp*1.5),nn_radius*2-(stokewidth*2)-Convert.ToSingle(progresswidthdp*1.5),nn_radius*2-(stokewidth*2)-Convert.ToSingle(progresswidthdp*1.5));
            canvas.DrawArc(oval, progresssstartangle, progresssendangle, false, nn_paint);

            //draw avatarcontainer (innercircle)
            nn_paint.SetStyle(Paint.Style.Fill);
            nn_paint.Color=nn_innercontainercolor;
            canvas.DrawCircle(center,center, nn_radius-progresswidth-stokewidth*2, nn_paint);
        }
开发者ID:MADMUC,项目名称:TAP5050,代码行数:32,代码来源:AvatarProgressRelativeLayout.cs


示例11: CircleDrawable

 public CircleDrawable(Bitmap bmp)
 {
     this.bmp = bmp;
     this.bmpShader = new BitmapShader(bmp, Shader.TileMode.Clamp, Shader.TileMode.Clamp);
     this.paint = new Paint() { AntiAlias = true };
     this.paint.SetShader(bmpShader);
     this.oval = new RectF();
 }
开发者ID:pmourfield,项目名称:xamarin-store-app,代码行数:8,代码来源:CircleDrawable.cs


示例12: DrawOutline

 private static void DrawOutline(Canvas canvas, IStyle style, RectF destination)
 {
     var vectorStyle = (style as VectorStyle);
     if (vectorStyle == null) return;
     if (vectorStyle.Outline == null) return;
     if (vectorStyle.Outline.Color == null) return;
     DrawRectangle(canvas, destination, vectorStyle.Outline.Color);
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:8,代码来源:RasterRenderer.cs


示例13: DrawRectangle

 private static void DrawRectangle(Canvas canvas, RectF destination, Styles.Color outlineColor)
 {
     var paint = new Paint();
     paint.SetStyle(Paint.Style.Stroke);
     paint.Color = new AndroidColor(outlineColor.R, outlineColor.G, outlineColor.B, outlineColor.A);
     paint.StrokeWidth = 4;
     canvas.DrawRect(destination, paint);
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:8,代码来源:RasterRenderer.cs


示例14: DrawRectBounds

 public override void DrawRectBounds( FastColour colour, float lineWidth, int x, int y, int width, int height )
 {
     RectF rec = new RectF( x, y, x + width, y + height );
     Paint brush = GetOrCreateBrush( colour );
     brush.SetStyle( Paint.Style.Stroke );
     c.DrawRect( rec, brush );
     brush.SetStyle( Paint.Style.FillAndStroke );
 }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:8,代码来源:CanvasDrawer2D.cs


示例15: Clear

 public override void Clear( FastColour colour, int x, int y, int width, int height )
 {
     RectF rec = new RectF( x, y, x + width, y + height );
     Paint brush = GetOrCreateBrush( colour );
     brush.AntiAlias = false;
     c.DrawRect( rec, brush );
     brush.AntiAlias = true;
 }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:8,代码来源:CanvasDrawer2D.cs


示例16: SetFrame

		protected override bool SetFrame (int l, int t, int r, int b)
		{
			bool changed = base.SetFrame(l, t, r, b);
	        mBounds = new Rect(0, 0, r - l, b - t);
	        mBoundsF = new RectF(mBounds);
	        mBorderDrawable.Bounds = mBounds;
	        mMaskDrawable.Bounds = mBounds;
	        return changed;
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:9,代码来源:BezelImageView.cs


示例17: HaveSameAspectRatio

		internal static bool HaveSameAspectRatio(RectF r1, RectF r2)
		{
			// Reduces precision to avoid problems when comparing aspect ratios.
			float srcRectRatio = Truncate(GetRectRatio(r1), 2);
			float dstRectRatio = Truncate(GetRectRatio(r2), 2);

			// Compares aspect ratios that allows for a tolerance range of [0, 0.01] 
			return (Math.Abs(srcRectRatio - dstRectRatio) <= 0.01f);
		}
开发者ID:Julien-Mialon,项目名称:MaterialViewPager.Xamarin,代码行数:9,代码来源:MathUtils.cs


示例18: RoundRectDrawable

		public RoundRectDrawable (Color background, float radius)
		{
			this.radius = radius;
			this.paint = new Paint {
				Color = background,
				Dither = true,
				AntiAlias = true
			};
			this.bounds = new RectF ();
		}
开发者ID:adamgoodrich,项目名称:Moyeu,代码行数:10,代码来源:RoundRectDrawable.cs


示例19: Renderer

		public static IRenderer Renderer(AnimationMode mode, FitChartValue value, RectF drawingArea)
		{
			if (mode == AnimationMode.Linear)
			{
				return new LinearValueRenderer (drawingArea, value);
			}
			else
			{
				return new OverdrawValueRenderer (drawingArea, value);
			}
		}
开发者ID:frankcalise,项目名称:XamDroid.FitChart,代码行数:11,代码来源:RendererFactory.cs


示例20: GetBitmapFromSvgString

 public static Bitmap GetBitmapFromSvgString(string svgString, int width, int height)
 {
     var svg = SVGParser.ParseSVGFromString (svgString);
     var bmp = Bitmap.CreateBitmap (width, height, Bitmap.Config.Argb8888);
     using (var c = new Canvas (bmp)) {
         var dst = new RectF (0, 0, width, height);
         c.DrawPicture (svg.Picture, dst);
     }
     // Returns an immutable copy
     return Bitmap.CreateBitmap (bmp);
 }
开发者ID:Andrea,项目名称:FriendTab,代码行数:11,代码来源:SvgUtils.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Drawables.Drawable类代码示例发布时间:2022-05-24
下一篇:
C# Graphics.Rect类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap