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


C# Canvas.DrawOval方法代码示例

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


在下文中一共展示了Canvas.DrawOval方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DrawShape

 protected void DrawShape(Canvas canvas)
 {
   Paint paint = new Paint();
   paint.Color = Color;
   switch (Shape)
   {
     case ShapeEnum.RectangleShape:
       canvas.DrawRect(0, 0, ShapeWidth, ShapeHeight, paint);
       break;
     case ShapeEnum.OvalShape:
       canvas.DrawOval(new RectF(0, 0, ShapeWidth, ShapeHeight), paint);
       break;
     case ShapeEnum.TriangleShape:
         Path path = new Path();
         path.MoveTo(ShapeWidth / 2, 0);
         path.LineTo(ShapeWidth, ShapeHeight);
         path.LineTo(0,ShapeHeight);
         path.Close();
       canvas.DrawPath(path, paint);
       break;
     default:
       canvas.DrawCircle(ShapeWidth / 2, ShapeHeight / 2, ShapeWidth / 2, paint); 
       break;
   }
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:25,代码来源:ShapeView.cs

示例3: Draw

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

            var element = Element as CircleView;
            var paint = new Paint ();

            paint.SetStyle (Paint.Style.FillAndStroke);
            paint.SetPathEffect(new DashPathEffect
                (new float[] {element.StrokeDash, element.StrokeDash}, 0.0f));

            using (var rect = new RectF (Left, Top, Right, Bottom)) {
                canvas.DrawOval (new RectF (Left, Top, Right, Bottom), paint);
            }
        }
开发者ID:pragmaticlogic,项目名称:athena,代码行数:15,代码来源:CircleViewRenderer.cs

示例4: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            var r = CenterX - _paint.StrokeWidth * 0.5f;

            canvas.Translate(CenterX, CenterX);

            canvas.DrawOval(new RectF(-r, -r, r, r), _paint);
            canvas.DrawCircle(0, 0, CenterRadius, _centerPaint);

            if (_trackingCenter)
            {
                var c = _centerPaint.Color;
                _centerPaint.SetStyle(Paint.Style.Stroke);

                _centerPaint.Alpha = _highlightCenter ? 255 : 128;

                canvas.DrawCircle(0, 0,
                                  CenterRadius + _centerPaint.StrokeWidth,
                                  _centerPaint);

                _centerPaint.SetStyle(Paint.Style.Fill);
                _centerPaint.Color = c;
            }
        }
开发者ID:Cheesebaron,项目名称:MonoDroid.ColorPickers,代码行数:24,代码来源:RoundColorPickerView.cs

示例5: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);
            float r = strokeWidth - myPaint.StrokeWidth * 0.5f;
            canvas.Translate((float)wowZapp.LaffOutOut.Singleton.ScreenXWidth / 1.5f, (float)wowZapp.LaffOutOut.Singleton.ScreenYHeight / 2.5f);
            canvas.DrawOval(new RectF(-r, -r, r, r), myPaint);
            canvas.DrawRect(new RectF(0f, 0f, 0f, 0f), myCenterPaint);

            if (trackingCentre)
            {
                Color c = myCenterPaint.Color;
                myCenterPaint.SetStyle(Paint.Style.Stroke);
                myCenterPaint.Alpha = (highlightCentre == true ? 0xff : 0x80);
                Rect rect = new Rect(0, 0, 0, 0);
                myCenterPaint.SetStyle(Paint.Style.Fill);
                myCenterPaint.Color = c;
                canvas.DrawRect(rect, myCenterPaint);
            }
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:19,代码来源:ColorPickerActivity.cs

示例6: Draw

 public override void Draw(Canvas canvas)
 {
     if (_mOval)
     {
         if (_mBorderWidth > 0)
         {
             canvas.DrawOval(_mDrawableRect, _mBitmapPaint);
             canvas.DrawOval(_mBorderRect, _mBorderPaint);
         }
         else
         {
             canvas.DrawOval(_mDrawableRect, _mBitmapPaint);
         }
     }
     else
     {
         if (_mBorderWidth > 0)
         {
             canvas.DrawRoundRect(_mDrawableRect, Math.Max(_mCornerRadius, 0),
                 Math.Max(_mCornerRadius, 0), _mBitmapPaint);
             canvas.DrawRoundRect(_mBorderRect, _mCornerRadius, _mCornerRadius, _mBorderPaint);
         }
         else
         {
             canvas.DrawRoundRect(_mDrawableRect, _mCornerRadius, _mCornerRadius, _mBitmapPaint);
         }
     }
 }
开发者ID:herrskytte,项目名称:RoundedImageView,代码行数:28,代码来源:RoundedDrawable.cs

示例7: Draw

 public override void Draw(Canvas canvas)
 {
     canvas.DrawOval(oval, paint);
 }
开发者ID:pmourfield,项目名称:xamarin-store-app,代码行数:4,代码来源:CircleDrawable.cs

示例8: Draw

 public override void Draw(Canvas canvas)
 {
     canvas.DrawOval(mRectF, mPaint);
 }
开发者ID:GSDan,项目名称:Speeching_Client,代码行数:4,代码来源:RoundedDrawable.cs

示例9: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw (canvas);
            float r = 100 - myPaint.StrokeWidth * 0.5f;
            float outr = 120;
            canvas.Translate (144f, 140f);
            canvas.DrawOval (new RectF (-r, -r, r, r), myPaint);
            canvas.DrawOval (new RectF (-outr, -outr, outr, outr), myOuterPaint);
            canvas.DrawRect (new RectF (-50f, 140f, 100f, 160f), myCenterPaint);

            if (trackingCentre) {
                Color c = myCenterPaint.Color;
                myCenterPaint.SetStyle (Paint.Style.Stroke);
                myCenterPaint.Alpha = (highlightCentre == true ? 0xff : 0x80);
                Rect rect = new Rect (-50, 140, 100, 160);
                myCenterPaint.SetStyle (Paint.Style.Fill);
                myCenterPaint.Color = c;
                canvas.DrawRect (rect, myCenterPaint);
            }
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:20,代码来源:ColorPicker.cs

示例10: GetOvalBitmap

		/// <summary>
		/// Gets the oval bitmap.
		/// </summary>
		/// <returns>The oval bitmap.</returns>
		/// <param name="bitmap">Bitmap.</param>
		private Bitmap GetOvalBitmap(Bitmap bitmap) 
		{
			Bitmap output = null;

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

				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, bitmap.Width, bitmap.Height);
				RectF rectF = new RectF(rect);

				paint.AntiAlias = true;
				canvas.DrawARGB(0, 0, 0, 0);
				paint.Color = Color.Red;
				canvas.DrawOval(rectF, paint);

				paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
				canvas.DrawBitmap(bitmap, rect, rect, paint);
			}

			return output;
		}
开发者ID:newky2k,项目名称:GravatarMobile,代码行数:29,代码来源:GravatarView.cs

示例11: OnDraw

        //@SuppressLint("DrawAllocation")
        //@Override
        protected override void OnDraw(Canvas canvas)
        {

            int centerX = Width / 2;
            int centerY = Height / 2;

            // drawing color wheel

            canvas.DrawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY - colorWheelRadius, null);

            // drawing color view

            colorViewPaint.Color = Color.HSVToColor(colorHSV);
            canvas.DrawPath(colorViewPath, colorViewPaint);

            // drawing value slider

            float[] hsv = new float[] { colorHSV[0], colorHSV[1], 1f };

            SweepGradient sweepGradient = new SweepGradient(centerX, centerY, new int[] { Color.Black, Color.HSVToColor(hsv), Color.White }, null);
            sweepGradient.SetLocalMatrix(gradientRotationMatrix);
            valueSliderPaint.SetShader(sweepGradient);

            canvas.DrawPath(valueSliderPath, valueSliderPaint);

            // drawing color wheel pointer

            float hueAngle = (float)Math.ToRadians(colorHSV[0]);
            int colorPointX = (int)(-Math.Cos(hueAngle) * colorHSV[1] * colorWheelRadius) + centerX;
            int colorPointY = (int)(-Math.Sin(hueAngle) * colorHSV[1] * colorWheelRadius) + centerY;

            float pointerRadius = 0.075f * colorWheelRadius;
            int pointerX = (int)(colorPointX - pointerRadius / 2);
            int pointerY = (int)(colorPointY - pointerRadius / 2);

            colorPointerCoords.Set(pointerX, pointerY, pointerX + pointerRadius, pointerY + pointerRadius);
            canvas.DrawOval(colorPointerCoords, colorPointerPaint);

            // drawing value pointer

            valuePointerPaint.Color = Color.HSVToColor(new float[] { 0f, 0f, 1f - colorHSV[2] });

            double valueAngle = (colorHSV[2] - 0.5f) * Math.Pi;
            float valueAngleX = (float)Math.Cos(valueAngle);
            float valueAngleY = (float)Math.Sin(valueAngle);

            canvas.DrawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY * innerWheelRadius + centerY, valueAngleX * outerWheelRadius + centerX,
                    valueAngleY * outerWheelRadius + centerY, valuePointerPaint);

            // drawing pointer arrow

            if (arrowPointerSize > 0)
            {
                drawPointerArrow(canvas);
            }

        }
开发者ID:skywolf888,项目名称:SystemBarTint.Net,代码行数:59,代码来源:ColorPicker.cs

示例12: OnDraw

            protected override void OnDraw(Canvas canvas)
            {
                lock (this) {
                    if (mBitmap != null) {
                        Path path = mPath;
                        int outer = new Color (192, 192, 192);
                        int inner = new Color (255, 112, 16);

                        if (mLastX >= mMaxX) {
                            mLastX = 0;
                            Canvas cavas = mCanvas;
                            float yoffset = mYOffset;
                            float maxx = mMaxX;
                            float oneG = SensorManager.StandardGravity * mScale[0];
                            paint.Color = new Color (170, 170, 170);
                            cavas.DrawColor (Color.Black);
                            cavas.DrawLine (0, yoffset, maxx, yoffset, paint);
                            cavas.DrawLine (0, yoffset + oneG, maxx, yoffset + oneG, paint);
                            cavas.DrawLine (0, yoffset - oneG, maxx, yoffset - oneG, paint);
                        }
                        canvas.DrawBitmap (mBitmap, 0, 0, null);

                        float[] values = mOrientationValues;
                        if (mWidth < mHeight) {
                            float w0 = mWidth * 0.333333f;
                            float w = w0 - 32;
                            float x = w0 * 0.5f;
                            for (int i = 0; i < 3; i++) {
                                canvas.Save (SaveFlags.Matrix);
                                canvas.Translate (x, w * 0.5f + 4.0f);
                                canvas.Save (SaveFlags.Matrix);
                                paint.Color = outer;
                                canvas.Scale (w, w);
                                canvas.DrawOval (mRect, paint);
                                canvas.Restore ();
                                canvas.Scale (w - 5, w - 5);
                                paint.Color = inner;
                                canvas.Rotate (-values[i]);
                                canvas.DrawPath (path, paint);
                                canvas.Restore ();
                                x += w0;
                            }
                        } else {
                            float h0 = mHeight * 0.333333f;
                            float h = h0 - 32;
                            float y = h0 * 0.5f;
                            for (int i = 0; i < 3; i++) {
                                canvas.Save (SaveFlags.Matrix);
                                canvas.Translate (mWidth - (h * 0.5f + 4.0f), y);
                                canvas.Save (SaveFlags.Matrix);
                                paint.Color = outer;
                                canvas.Scale (h, h);
                                canvas.DrawOval (mRect, paint);
                                canvas.Restore ();
                                canvas.Scale (h - 5, h - 5);
                                paint.Color = inner;
                                canvas.Rotate (-values[i]);
                                canvas.DrawPath (path, paint);
                                canvas.Restore ();
                                y += h0;
                            }
                        }

                    }
                }
            }
开发者ID:rudini,项目名称:monodroid-samples,代码行数:66,代码来源:Sensors.cs

示例13: DrawOval

			void DrawOval (Canvas canvas, float x, float y, float major, float minor,
				float orientation, Paint paint)
			{
				canvas.Save (SaveFlags.Matrix);
				canvas.Rotate ((float) (orientation * 180 / Math.PI), x, y);
				mReusableOvalRect.Left = x - minor / 2;
				mReusableOvalRect.Right = x + minor / 2;
				mReusableOvalRect.Top = y - major / 2;
				mReusableOvalRect.Bottom = y + major / 2;
				canvas.DrawOval (mReusableOvalRect, paint);
				canvas.Restore ();
			}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:12,代码来源:TouchPaint.cs


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