예제 #1
0
        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();
        }
예제 #2
0
        // 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();
        }