//public static CGPath ToGCPath(this UIBezierPath bezierPath)
        //{
        //    var path = new CGPath();
        //    CGPoint[] points;
        //    for (int i = 0; i < (int)bezierPath.RetainCount; i++)
        //    {
        //        var type = bezierPath. ElementAt(i, out points);
        //        switch (type)
        //        {
        //            case UIBezierPathElement.MoveTo:
        //                path.MoveToPoint(points[0]);
        //                break;
        //            case NSBezierPathElement.LineTo:
        //                path.AddLineToPoint(points[0]);
        //                break;
        //            case NSBezierPathElement.CurveTo:
        //                path.AddCurveToPoint(points[2], points[1], points[0]);
        //                break;
        //            case NSBezierPathElement.ClosePath:
        //                path.CloseSubpath();
        //                break;
        //        }
        //    }
        //    return path;
        //}

        public static void Configure(this UIView figmaLineView, FigmaLine figmaLine)
        {
            Configure(figmaLineView, (FigmaVectorEntity)figmaLine);

            var fills = figmaLine.fills.OfType <FigmaPaint>().FirstOrDefault();

            if (fills != null)
            {
                figmaLineView.Layer.BackgroundColor = fills.color.ToUIColor().CGColor;
            }

            var absolute  = figmaLine.absoluteBoundingBox;
            var lineWidth = absolute.width == 0 ? figmaLine.strokeWeight : absolute.width;

            var constraintWidth = figmaLineView.WidthAnchor.ConstraintEqualTo(lineWidth);

            constraintWidth.Priority = (uint)UILayoutPriority.DefaultLow;
            constraintWidth.Active   = true;

            var lineHeight = absolute.height == 0 ? figmaLine.strokeWeight : absolute.height;

            var constraintHeight = figmaLineView.HeightAnchor.ConstraintEqualTo(lineHeight);

            constraintHeight.Priority = (uint)UILayoutPriority.DefaultLow;
            constraintHeight.Active   = true;
        }
        public static void Configure(this Xamarin.Forms.View view, FigmaLine figmaLine)
        {
            Configure(view, (FigmaVectorEntity)figmaLine);

            //var fills = figmaLine.fills.OfType<FigmaPaint>().FirstOrDefault();
            //if (fills != null)
            //{
            //    view.BackgroundColor = fills.color.ToFormsColor();
            //}
        }
Example #3
0
        public static void Configure(this Widget view, FigmaLine child)
        {
            Configure(view, (FigmaVectorEntity)child);

            var fills = child.fills.OfType <FigmaPaint>().FirstOrDefault();

            if (fills != null && child.fills.Length > 0)
            {
                if (child.fills[0].color.a > 0)
                {
                    if (view is Fixed fixedView)
                    {
                        fixedView.HasWindow = true;
                        fixedView.ModifyBg(StateType.Normal, child.fills[0].color.ToGdkColor());
                    }
                }
            }
        }
Example #4
0
        public static void Configure(this LineTransparentControl figmaLineView, FigmaLine figmaLine)
        {
            Configure(figmaLineView, (FigmaVectorEntity)figmaLine);

            var fills = figmaLine.fills.OfType <FigmaPaint> ().FirstOrDefault();

            if (fills != null)
            {
                figmaLineView.BackColor = fills.color.ToColor();
            }

            var absolute  = figmaLine.absoluteBoundingBox;
            var lineWidth = absolute.width == 0 ? figmaLine.strokeWeight : absolute.width;

            figmaLineView.Width = (int)lineWidth;

            var lineHeight = absolute.height == 0 ? figmaLine.strokeWeight : absolute.height;

            figmaLineView.Height = (int)lineHeight;
        }
Example #5
0
        public static void Configure(this FrameworkElement view, FigmaLine child)
        {
            Configure(view, (FigmaVectorEntity)child);

            if (view is Panel canvas)
            {
                if (child.HasStrokes && child.strokes[0].color != null)
                {
                    canvas.Background = child.strokes[0].color.ToColor();
                }
            }

            var absolute  = child.absoluteBoundingBox;
            var lineWidth = absolute.Width == 0 ? child.strokeWeight : absolute.Width;

            view.Width = (int)lineWidth;

            var lineHeight = absolute.Height == 0 ? child.strokeWeight : absolute.Height;

            view.Height = (int)lineHeight;
        }
Example #6
0
        public static void Configure(this NSView figmaLineView, FigmaLine figmaLine)
        {
            //we draw a figma line from images or svg
            Configure(figmaLineView, (FigmaNode)figmaLine);

            var absolute  = figmaLine.absoluteBoundingBox;
            var lineWidth = absolute.Width == 0 ? figmaLine.strokeWeight : absolute.Width;

            var constraintWidth = figmaLineView.WidthAnchor.ConstraintEqualToConstant(lineWidth);

            constraintWidth.Priority = (uint)NSLayoutPriority.DefaultLow;
            constraintWidth.Active   = true;

            var lineHeight = absolute.Height == 0 ? figmaLine.strokeWeight : absolute.Height;

            var constraintHeight = figmaLineView.HeightAnchor.ConstraintEqualToConstant(lineHeight);

            constraintHeight.Priority = (uint)NSLayoutPriority.DefaultLow;
            constraintHeight.Active   = true;

            figmaLineView.AlphaValue = figmaLine.opacity;
        }