コード例 #1
0
        public static void FillRoundedRectangle(this ICanvas target, Rectangle rect, double topLeftCornerRadius, double topRightCornerRadius, double bottomLeftCornerRadius, double bottomRightCornerRadius)
        {
            var path = new PathF();

            path.AppendRoundedRectangle((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height, (float)topLeftCornerRadius, (float)topRightCornerRadius, (float)bottomLeftCornerRadius, (float)bottomRightCornerRadius);
            target.FillPath(path);
        }
コード例 #2
0
        public static void FillRoundedRectangle(this ICanvas target, RectangleF rect, float topLeftCornerRadius, float topRightCornerRadius, float bottomLeftCornerRadius, float bottomRightCornerRadius)
        {
            var path = new PathF();

            path.AppendRoundedRectangle(rect, topLeftCornerRadius, topRightCornerRadius, bottomLeftCornerRadius, bottomRightCornerRadius);
            target.FillPath(path);
        }
コード例 #3
0
ファイル: RoundedRectangle.cs プロジェクト: twsouthwick/Comet
        public override PathF PathForBounds(RectangleF rect)
        {
            var path = new PathF();

            path.AppendRoundedRectangle(rect, _cornerRadius);
            return(path);
        }
コード例 #4
0
        public static void DrawRoundedRectangle(this ICanvas target, float x, float y, float width, float height, float topLeftCornerRadius, float topRightCornerRadius, float bottomLeftCornerRadius, float bottomRightCornerRadius)
        {
            var path = new PathF();

            path.AppendRoundedRectangle(x, y, width, height, topLeftCornerRadius, topRightCornerRadius, bottomLeftCornerRadius, bottomRightCornerRadius);
            target.DrawPath(path);
        }
コード例 #5
0
        public PathF PathForBounds(Rect rect)
        {
            var path = new PathF();

            path.AppendRoundedRectangle(rect, (float)RadiusY + (float)RadiusX);

            return(path);
        }
コード例 #6
0
        public override PathF PathForBounds(Rectangle rect)
        {
            var path       = new PathF();
            var cornerSize = (float)Math.Min(rect.Width, rect.Height) / 2;

            path.AppendRoundedRectangle(rect, cornerSize);
            return(path);
        }
コード例 #7
0
        public PathF PathForBounds(Rectangle rect)
        {
            var path = new PathF();

            path.AppendRoundedRectangle(rect, (float)CornerRadius.TopLeft, (float)CornerRadius.TopRight, (float)CornerRadius.BottomLeft, (float)CornerRadius.BottomRight);

            return(path);
        }
コード例 #8
0
        public override PathF PathForBounds(Rectangle rect)
        {
            var cornerRadius = (float)(Orientation == Orientation.Horizontal ? rect.Height : rect.Width) / 2f;
            var path         = new PathF();

            path.AppendRoundedRectangle(rect, cornerRadius);
            return(path);
        }
コード例 #9
0
        PathF IShape.PathForBounds(Rectangle bounds)
        {
            var path = new PathF();

            path.AppendRoundedRectangle(
                bounds,
                (float)CornerRadius.TopLeft,
                (float)CornerRadius.TopRight,
                (float)CornerRadius.BottomLeft,
                (float)CornerRadius.BottomRight);

            return(path);
        }
コード例 #10
0
        public override PathF GetPath()
        {
            var path = new PathF();

            float x            = (float)StrokeThickness / 2;
            float y            = (float)StrokeThickness / 2;
            float w            = (float)(Width - StrokeThickness);
            float h            = (float)(Height - StrokeThickness);
            float cornerRadius = (float)Math.Max(RadiusX, RadiusY);

            // TODO: Create specific Path taking into account RadiusX and RadiusY
            path.AppendRoundedRectangle(x, y, w, h, cornerRadius);
            return(path);
        }
コード例 #11
0
ファイル: RoundRectangle.Impl.cs プロジェクト: sung-su/maui
        public override PathF GetPath()
        {
            var path = new PathF();

            float x = (float)StrokeThickness / 2;
            float y = (float)StrokeThickness / 2;

            float w = (float)(Width - StrokeThickness);
            float h = (float)(Height - StrokeThickness);

            float topLeftCornerRadius     = (float)CornerRadius.TopLeft;
            float topRightCornerRadius    = (float)CornerRadius.TopRight;
            float bottomLeftCornerRadius  = (float)CornerRadius.BottomLeft;
            float bottomRightCornerRadius = (float)CornerRadius.BottomRight;

            path.AppendRoundedRectangle(x, y, w, h, topLeftCornerRadius, topRightCornerRadius, bottomLeftCornerRadius, bottomRightCornerRadius);

            return(path);
        }
コード例 #12
0
ファイル: BorderDrawable.cs プロジェクト: sung-su/maui
        PathF GetPath(float width, float height, CornerRadius cornerRadius, float strokeThickness)
        {
            var path = new PathF();

            float x = (float)strokeThickness / 2;
            float y = (float)strokeThickness / 2;

            float w = (float)(width - strokeThickness);
            float h = (float)(height - strokeThickness);

            float topLeftCornerRadius     = (float)cornerRadius.TopLeft;
            float topRightCornerRadius    = (float)cornerRadius.TopRight;
            float bottomLeftCornerRadius  = (float)cornerRadius.BottomLeft;
            float bottomRightCornerRadius = (float)cornerRadius.BottomRight;

            path.AppendRoundedRectangle(x, y, w, h, topLeftCornerRadius, topRightCornerRadius, bottomLeftCornerRadius, bottomRightCornerRadius);

            return(path);
        }
コード例 #13
0
        public void Clip(IRectangleMask mask, DrawContext context)
        {
            if (!mask.IsActive)
            {
                return;
            }

            var bounds = mask.Size.GetDrawRectangle(context.CanvasRect, context.PixelScaling);

            var topLeft     = GetCornerPoint(mask.Corners.TopLeft, bounds, context.PixelScaling);
            var topRight    = GetCornerPoint(mask.Corners.TopRight, bounds, context.PixelScaling);
            var bottomLeft  = GetCornerPoint(mask.Corners.BottomLeft, bounds, context.PixelScaling);
            var bottomRight = GetCornerPoint(mask.Corners.BottomRight, bounds, context.PixelScaling);

            var path = new PathF();

            path.AppendRoundedRectangle(bounds, topLeft.X, topRight.X, bottomLeft.X, bottomRight.X);

            using var layout = ShapeMaskLayout.Create(mask, bounds, context, false);
            context.Canvas.ClipPath(path);
        }
コード例 #14
0
 public static void AppendRoundedRectangle(this PathF path, Rectangle rect, float radius) => path.AppendRoundedRectangle((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height, radius);