Beispiel #1
0
        protected void UpdatePathShape()
        {
            if (_path != null && !_drawable.Bounds.IsEmpty)
            {
                _drawable.Shape = new PathShape(_path, _drawable.Bounds.Width(), _drawable.Bounds.Height());
            }
            else
            {
                _drawable.Shape = null;
            }

            if (_path != null)
            {
                using (APath fillPath = new APath())
                {
                    _drawable.Paint.StrokeWidth = 0.01f;
                    _drawable.Paint.SetStyle(Paint.Style.Stroke);
                    _drawable.Paint.GetFillPath(_path, fillPath);
                    fillPath.ComputeBounds(_pathFillBounds, false);
                    _drawable.Paint.StrokeWidth = _strokeWidth;
                }
            }
            else
            {
                _pathFillBounds.SetEmpty();
            }

            _fillShader = null;
            UpdatePathStrokeBounds();
        }
        protected void CreatePathShape()
        {
            if (Path != null && !drawable.Bounds.IsEmpty)
            {
                drawable.Shape = new PathShape(Path, drawable.Bounds.Width(), drawable.Bounds.Height());
            }
            else
            {
                drawable.Shape = null;
            }

            // Find the path bounds.
            // Can't use ComputeFounds on the path because that includes Bezier control points.
            // Need to obtain the fill path first.
            if (Path != null)
            {
                using (droidGraphics.Path fillPath = new droidGraphics.Path())
                {
                    drawable.Paint.StrokeWidth = 0.01f;
                    drawable.Paint.SetStyle(droidGraphics.Paint.Style.Stroke);
                    drawable.Paint.GetFillPath(Path, fillPath);
                    fillPath.ComputeBounds(pathFillBounds, false);
                    drawable.Paint.StrokeWidth = strokeWidth;
                }
            }
            else
            {
                pathFillBounds.SetEmpty();
            }

            fillShader = null;              // really only necessary for LinearGradientBrush
            CalculatePathStrokeBounds();
        }
Beispiel #3
0
        private Windows.Foundation.Rect GetPathBoundingBox(Android.Graphics.Path path)
        {
            //There is currently a bug here, Android's ComputeBounds includes the control points of a Bezier path
            //which can result in improper positioning when aligning paths with Bezier segments.
            var pathBounds = new RectF();

            path.ComputeBounds(pathBounds, true);
            return(pathBounds);
        }
        void UpdatePathStrokeBounds()
        {
            if (_path != null)
            {
                using (APath strokePath = new APath())
                {
                    _drawable.Paint.SetStyle(Paint.Style.Stroke);
                    _drawable.Paint.GetFillPath(_path, strokePath);
                    strokePath.ComputeBounds(_pathStrokeBounds, false);
                }
            }
            else
            {
                _pathStrokeBounds.SetEmpty();
            }

            Invalidate();
        }
Beispiel #5
0
        void UpdatePathStrokeBounds()
        {
            if (_path != null)
            {
                using (APath strokePath = new APath())
                {
                    this.Paint.SetStyle(Paint.Style.Stroke);
                    this.Paint.GetFillPath(_path, strokePath);
                    strokePath.ComputeBounds(_pathStrokeBounds, false);
                }
            }
            else
            {
                _pathStrokeBounds.SetEmpty();
            }

            _strokeShader = null;
            //Invalidate();
        }
        // Set from above and when stroke width or style changes
        void CalculatePathStrokeBounds()
        {
            if (Path != null)
            {
                using (droidGraphics.Path strokePath = new droidGraphics.Path())
                {
                    drawable.Paint.SetStyle(droidGraphics.Paint.Style.Stroke);
                    drawable.Paint.GetFillPath(Path, strokePath);
                    strokePath.ComputeBounds(pathStrokeBounds, false);
                }
            }
            else
            {
                pathStrokeBounds.SetEmpty();
            }

            strokeShader = null;        // really only necessary of LinearGradientBrush
            Invalidate();
        }
Beispiel #7
0
		public void ensureComputedBoundsInclude(Path pPath) {
			pPath.ComputeBounds(this.mRect, false);
			this.ensureComputedBoundsInclude(this.mRect.Left, this.mRect.Top);
			this.ensureComputedBoundsInclude(this.mRect.Right, this.mRect.Bottom);
		}
        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);
                }
            }
        }