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


C# Paint.SetPathEffect方法代码示例

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


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

示例1: Initialize

        private void Initialize()
        {
            var scaledDensity = Context.Resources.DisplayMetrics.ScaledDensity;

            SetLayerType(LayerType.Software, null);

            _paintBorder = new Paint(PaintFlags.AntiAlias) { Color = Color.DarkGray };

            _paintGrid = new Paint(PaintFlags.AntiAlias) { Color = Color.LightGray };
            _paintGrid.SetStyle(Paint.Style.Stroke);
            _paintGrid.SetPathEffect(new DashPathEffect(new float[] { 5, 5 }, 0));
            _paintGrid.StrokeWidth = 5;

            _paintSubGrid = new Paint(PaintFlags.AntiAlias) { Color = Color.LightGray };
            _paintSubGrid.SetStyle(Paint.Style.Stroke);
            _paintSubGrid.SetPathEffect(new DashPathEffect(new float[] { 5, 5 }, 0));
            _paintSubGrid.StrokeWidth = 2;

            _paintPos = new Paint(PaintFlags.AntiAlias) { Color = Color.CornflowerBlue };

            _paintGridText = new Paint(PaintFlags.AntiAlias)
            {
                Color = Color.LightGray,
                TextSize = 20*scaledDensity
            };
        }
开发者ID:milindur,项目名称:MdkControlApp,代码行数:26,代码来源:JoystickView.cs

示例2: CreateAnimationDrawer

        public CreateAnimationDrawer(Context c, BrushItem brush, Canvas canvas, Bitmap myBmp, bool tooAdd = false, int cell = 1, string DrawerState = "brush_selection", Path pathToUse = null)
            : base(c)
        {
            myBitmap = myBmp;
            myCanvas = canvas;
            DrawerStateInternal = DrawerState;
            addOnly = tooAdd;
            status = 0;
            myPath = new Path();
            myPaint = new Paint(PaintFlags.Dither);
            myPaint.AntiAlias = true;
            myPaint.Dither = true;
            myPaint.SetStyle(Paint.Style.Stroke);
            myPaint.StrokeJoin = Paint.Join.Round;
            myPaint.StrokeWidth = brush.Thickness;
            myPaint.StrokeCap = Paint.Cap.Round;
            myPaint.SetARGB(colorUtil.a, colorUtil.r, colorUtil.g, colorUtil.b);

            if (brush.BrushType == AnimationTypesBrushType.Spray)
                myPaint.SetShadowLayer(brush.Thickness, 0, 0, ImageHelper.convWZColorToColor(brush.BrushColor));

            if (DrawerState == "brush_selection")
            {
                if (pathToUse != null)
                {
                    myBoundsPaint = new Paint();
                    myBoundsPaint = new Paint(PaintFlags.Dither);
                    myBoundsPaint.AntiAlias = true;
                    myBoundsPaint.Dither = true;
                    myBoundsPaint.SetStyle(Paint.Style.Stroke);
                    myBoundsPaint.StrokeJoin = Paint.Join.Round;
                    myBoundsPaint.StrokeWidth = 10f;
                    myBoundsPaint.StrokeCap = Paint.Cap.Round;
                    myBoundsPaint.SetARGB(255, 0, 0, 0);
                    myBoundsPaint.SetPathEffect(new DashPathEffect(new float[]
                    {
                        10f,
                        20f
                    }, 0));

                    myPath = pathToUse;
                    AnimationUtil.theCanvas.DrawPath(myPath, myPaint);
                    AnimationUtil.theCanvas.DrawPath(myPath, myPaint);

                    myBoundsRect = new RectF();
                    myPath.ComputeBounds(myBoundsRect, true);
                    AnimationUtil.theCanvas.DrawRect(myBoundsRect, myBoundsPaint);
                }
            }
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:50,代码来源:CreateAnimationDrawer.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: DrawHexagon

		void DrawHexagon (Canvas canvas)
		{
			// The extra padding is to avoid edges being clipped
			var padding = (int)TypedValue.ApplyDimension (ComplexUnitType.Dip, 8, Resources.DisplayMetrics);
			var halfHeight = (Height - padding) / 2;
			var side = (Width - padding) / 2;
			var foo = (int)Math.Sqrt (side * side - halfHeight * halfHeight);

			var path = hexagon ?? (hexagon = new Path ());
			hexagon.Reset ();
			path.MoveTo (Width / 2, padding / 2);
			path.RLineTo (-side / 2, 0);
			path.RLineTo (-foo, halfHeight);
			path.RLineTo (foo, halfHeight);
			path.RLineTo (side, 0);
			path.RLineTo (foo, -halfHeight);
			path.RLineTo (-foo, -halfHeight);
			path.Close ();

			var m = transformationMatrix ?? (transformationMatrix = new Matrix ());
			m.Reset ();
			var centerX = Width / 2;
			var centerY = Height / 2;
			m.PostRotate (Rotation, centerX, centerY);
			m.PostScale (ScaleX, ScaleY, centerX, centerY);
			path.Transform (m);

			if (hexagonPaint == null) {
				hexagonPaint = new Paint {
					Color = new Android.Graphics.Color (0x22, 0x76, 0xB9),
					AntiAlias = true,
				};
				hexagonPaint.SetPathEffect (new CornerPathEffect (30));
			}

			canvas.DrawPath (path, hexagonPaint);
		}
开发者ID:KiranKumarAlugonda,项目名称:xamarin-store-app,代码行数:37,代码来源:XamarinSpinnerView.cs

示例5: OnDraw

        /// <summary>
        ///     Implement this to do your drawing.
        /// </summary>
        /// <param name="canvas">the canvas on which the background will be drawn</param>
        /// <since version="Added in API level 1" />
        /// <remarks>
        ///     <para tool="javadoc-to-mdoc">Implement this to do your drawing.</para>
        ///     <para tool="javadoc-to-mdoc">
        ///         <format type="text/html">
        ///             <a href="http://developer.android.com/reference/android/view/View.html#onDraw(android.graphics.Canvas)"
        ///                 target="_blank">
        ///                 [Android Documentation]
        ///             </a>
        ///         </format>
        ///     </para>
        /// </remarks>
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);

            var r = new Rect(0, 0, canvas.Width, canvas.Height);
            var dAdjustedThicnkess = (float)Thickness * _dm;

            var paint = new Paint { Color = StrokeColor, StrokeWidth = dAdjustedThicnkess, AntiAlias = true };
            paint.SetStyle(Paint.Style.Stroke);
            switch (StrokeType)
            {
                case StrokeType.Dashed:
                    paint.SetPathEffect(new DashPathEffect(new[] { 6 * _dm, 2 * _dm }, 0));
                    break;
                case StrokeType.Dotted:
                    paint.SetPathEffect(new DashPathEffect(new[] { dAdjustedThicnkess, dAdjustedThicnkess }, 0));
                    break;
            }

            var thicknessOffset = (dAdjustedThicnkess) / 2.0f;

            var p = new Path();
            if (Orientation == SeparatorOrientation.Horizontal)
            {
                p.MoveTo(0, thicknessOffset);
                p.LineTo(r.Width(), thicknessOffset);
            }
            else
            {
                p.MoveTo(thicknessOffset, 0);
                p.LineTo(thicknessOffset, r.Height());
            }
            canvas.DrawPath(p, paint);
        }
开发者ID:JavierErdozain,项目名称:Events,代码行数:50,代码来源:SeparatorDroidView.cs

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

示例7: GetPenPaint

		Paint GetPenPaint (Pen pen)
		{
			var paint = new Paint (PaintFlags.AntiAlias);
			paint.SetStyle (Paint.Style.Stroke);
			paint.SetARGB (pen.Color.A, pen.Color.R, pen.Color.G, pen.Color.B);
			paint.StrokeWidth = (float)pen.Width;

            if (pen.DashPattern != null && pen.DashPattern.Any ()) {
                var dashPathEffect = new DashPathEffect(pen.DashPattern.ToArray(), 0);
                paint.SetPathEffect(dashPathEffect);
            }

			return paint;
		}
开发者ID:stevetsang,项目名称:NGraphics,代码行数:14,代码来源:AndroidPlatform.cs

示例8: OnDraw

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

			var r = new Rect (0,0,canvas.Width,canvas.Height);
			float dAdjustedThicnkess = (float)this.Thickness * dm;
		

			var paint = new Paint()
			{
				Color = this.StrokeColor,
				StrokeWidth = dAdjustedThicnkess,
				AntiAlias = true
			
			};
			paint.SetStyle(Paint.Style.Stroke);
			switch(StrokeType) {
			case StrokeType.Dashed:
				paint.SetPathEffect(new DashPathEffect(new float[]{ 6*dm, 2*dm}, 0));
				break;
			case StrokeType.Dotted:
				paint.SetPathEffect(new DashPathEffect(new float[]{ dAdjustedThicnkess, dAdjustedThicnkess}, 0));
				break;
			default:

				break;
			}

			var desiredTotalSpacing = (SpacingAfter + SpacingBefore)*dm;
			float leftForSpacing = 0;
			float actualSpacingBefore = 0;
			float actualSpacingAfter = 0;
			if(Orientation == SeparatorOrientation.Horizontal){
				leftForSpacing = r.Height() - dAdjustedThicnkess;
			}else{
				leftForSpacing = r.Width() - dAdjustedThicnkess;
			}
			if(desiredTotalSpacing > 0) {
				float spacingCompressionRatio = (float)(leftForSpacing / desiredTotalSpacing) ;
				actualSpacingBefore = (float)SpacingBefore*dm * spacingCompressionRatio;
				actualSpacingAfter = (float)SpacingAfter*dm * spacingCompressionRatio;
			}else{
				actualSpacingBefore = 0;
				actualSpacingAfter = 0;
			}
			float thicknessOffset = (dAdjustedThicnkess)/2.0f;



			Path p = new Path();
			if(Orientation == SeparatorOrientation.Horizontal){
				p.MoveTo(0, actualSpacingBefore + thicknessOffset);
				p.LineTo(r.Width(), actualSpacingBefore + thicknessOffset);
			}else{
				p.MoveTo(actualSpacingBefore+thicknessOffset, 0);
				p.LineTo(actualSpacingBefore+thicknessOffset, r.Height());
			}
			canvas.DrawPath(p, paint);
		}
开发者ID:adiuvo,项目名称:Xamarin-Forms-Labs,代码行数:59,代码来源:SeparatorDroidView.cs


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