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


C# RectF.Set方法代码示例

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


在下文中一共展示了RectF.Set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: parse

		public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint, RectF pRect) {
			float x = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X, 0f);
			float y = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y, 0f);
			float width = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_WIDTH, 0f);
			float height = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_HEIGHT, 0f);

			pRect.Set(x, y, x + width, y + height);

			float? rX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_X);
			float? rY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_Y);

			bool rXSpecified = rX != null && rX >= 0;
			bool rYSpecified = rY != null && rY >= 0;

			bool rounded = rXSpecified || rYSpecified;
			float rx;
			float ry;
			if(rXSpecified && rYSpecified) {
				rx = Math.Min(rX.Value, width * 0.5f);
				ry = Math.Min(rY.Value, height * 0.5f);
			} else if(rXSpecified) {
				ry = rx = Math.Min(rX.Value, width * 0.5f);
			} else if(rYSpecified) {
				rx = ry = Math.Min(rY.Value, height * 0.5f);
			} else {
				rx = 0;
				ry = 0;
			}

			bool fill = pSVGPaint.setFill(pSVGProperties);
			if (fill) {
				if(rounded) {
					pCanvas.DrawRoundRect(pRect, rx, ry, pSVGPaint.getPaint());
				} else {
					pCanvas.DrawRect(pRect, pSVGPaint.getPaint());
				}
			}

			bool stroke = pSVGPaint.setStroke(pSVGProperties);
			if (stroke) {
				if(rounded) {
					pCanvas.DrawRoundRect(pRect, rx, ry, pSVGPaint.getPaint());
				} else {
					pCanvas.DrawRect(pRect, pSVGPaint.getPaint());
				}
			}

			if(fill || stroke) {
				pSVGPaint.ensureComputedBoundsInclude(x, y, width, height);
			}
		}
开发者ID:jdluzen,项目名称:xamsvg,代码行数:51,代码来源:SVGRectParser.cs

示例3: OnSizeChanged

		protected override void OnSizeChanged (int w, int h, int oldW, int oldH)
		{	
			HEIGHT = h;
			WIDTH = w;

			HALF_WIDTH = (int)Math.Round ((Double)w / 2);
			HALF_HEIGHT = (int)(Math.Round ((Double)h / 2));

			//int OFFSET = mCenterOval.Width () / 3.0f;

			mCenterOval = new RectF ();
			//float OFFSET = 140f;
			//Change the OFFSET to relative value according to the screen width
			float OFFSET = WIDTH / 5;
			//mCenterOval.Set (OFFSET, OFFSET, WIDTH - OFFSET, WIDTH - OFFSET);
			//move the mCenterOval a little bit up
			mCenterOval.Set (OFFSET, OFFSET * (float)0.5, WIDTH - OFFSET, WIDTH - (float)1.5 * OFFSET);

			mCx = (int)Math.Round (mCenterOval.CenterX ());
			mCy = (int)Math.Round (mCenterOval.CenterY ());
			mRadius = (int)Math.Round (mCenterOval.Width () / 2.0f);

			mInnerCircleRadius = mRadius - (mPaint.StrokeWidth * 0.9f);

			updateCircleCoordinate (mCx, 0);
		}
开发者ID:KiranKumarAlugonda,项目名称:TXTSHD,代码行数:26,代码来源:ChartView.cs


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