예제 #1
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();

            Rect pixelRect = RectTransformUtility.PixelAdjustRect(rectTransform, canvas);

            OutlineProperties.UpdateAdjusted();
            ShadowProperties.UpdateAdjusted();

            UIShapesKit.Ellipses.SetRadius(
                ref radius,
                pixelRect.width,
                pixelRect.height,
                EllipseProperties
                );

            PointListProperties.GeneratorData.Width  = radius.x * 2.0f;
            PointListProperties.GeneratorData.Height = radius.y * 2.0f;

            EllipseProperties.UpdateAdjusted(radius, OutlineProperties.GetOuterDistace());
            ArcProperties.UpdateAdjusted(EllipseProperties.AdjustedResolution, EllipseProperties.BaseAngle);
            AntiAliasingProperties.UpdateAdjusted(canvas);

            PointListProperties.GeneratorData.Resolution = EllipseProperties.AdjustedResolution * 2;
            PointListProperties.GeneratorData.Length     = ArcProperties.Length;

            switch (ArcProperties.Direction)
            {
            case UIShapesKit.Arcs.ArcProperties.ArcDirection.Forward:
                PointListProperties.GeneratorData.Direction        = 1.0f;
                PointListProperties.GeneratorData.FloatStartOffset = EllipseProperties.BaseAngle * 0.5f;
                break;

            case UIShapesKit.Arcs.ArcProperties.ArcDirection.Centered:
                PointListProperties.GeneratorData.Direction        = -1.0f;
                PointListProperties.GeneratorData.FloatStartOffset = EllipseProperties.BaseAngle * 0.5f + (ArcProperties.Length * 0.5f);
                break;

            case UIShapesKit.Arcs.ArcProperties.ArcDirection.Backward:
                PointListProperties.GeneratorData.Direction        = -1.0f;
                PointListProperties.GeneratorData.FloatStartOffset = EllipseProperties.BaseAngle * 0.5f;
                break;
            }

            // shadows
            if (ShadowProperties.ShadowsEnabled)
            {
                if (AntiAliasingProperties.Adjusted > 0.0f)
                {
                    edgeGradientData.SetActiveData(
                        1.0f,
                        0.0f,
                        AntiAliasingProperties.Adjusted
                        );
                }
                else
                {
                    edgeGradientData.Reset();
                }

                // use segment if LineWeight is overshooting the center
                if (
                    (
                        OutlineProperties.Type == GeoUtils.OutlineProperties.LineType.Center ||
                        OutlineProperties.Type == GeoUtils.OutlineProperties.LineType.Inner
                    ) &&
                    (
                        radius.x + OutlineProperties.GetInnerDistace() < 0.0f ||
                        radius.y + OutlineProperties.GetInnerDistace() < 0.0f
                    )
                    )
                {
                    if (OutlineProperties.Type == GeoUtils.OutlineProperties.LineType.Center)
                    {
                        radius *= 2.0f;
                    }

                    for (int i = 0; i < ShadowProperties.Shadows.Length; i++)
                    {
                        edgeGradientData.SetActiveData(
                            1.0f - ShadowProperties.Shadows[i].Softness,
                            ShadowProperties.Shadows[i].Size,
                            AntiAliasingProperties.Adjusted
                            );

                        UIShapesKit.Arcs.AddSegment(
                            ref vh,
                            ShadowProperties.GetCenterOffset(pixelRect.center, i),
                            radius,
                            EllipseProperties,
                            ArcProperties,
                            ShadowProperties.Shadows[i].Color,
                            GeoUtils.ZeroV2,
                            ref unitPositionData,
                            edgeGradientData
                            );
                    }
                }
                else
                {
                    for (int i = 0; i < ShadowProperties.Shadows.Length; i++)
                    {
                        edgeGradientData.SetActiveData(
                            1.0f - ShadowProperties.Shadows[i].Softness,
                            ShadowProperties.Shadows[i].Size,
                            AntiAliasingProperties.Adjusted
                            );

                        if (LineProperties.LineCap == UIShapesKit.Lines.LineProperties.LineCapTypes.Close)
                        {
                            UIShapesKit.Arcs.AddArcRing(
                                ref vh,
                                ShadowProperties.GetCenterOffset(pixelRect.center, i),
                                radius,
                                EllipseProperties,
                                ArcProperties,
                                OutlineProperties,
                                ShadowProperties.Shadows[i].Color,
                                GeoUtils.ZeroV2,
                                ref unitPositionData,
                                edgeGradientData
                                );
                        }
                        else
                        {
                            UIShapesKit.Lines.AddLine(
                                ref vh,
                                LineProperties,
                                PointListProperties,
                                ShadowProperties.GetCenterOffset(pixelRect.center, i),
                                OutlineProperties,
                                ShadowProperties.Shadows[i].Color,
                                GeoUtils.ZeroV2,
                                ref PointsData,
                                edgeGradientData
                                );
                        }
                    }
                }
            }

            // fill
            if (ShadowProperties.ShowShape)
            {
                if (AntiAliasingProperties.Adjusted > 0.0f)
                {
                    edgeGradientData.SetActiveData(
                        1.0f,
                        0.0f,
                        AntiAliasingProperties.Adjusted
                        );
                }
                else
                {
                    edgeGradientData.Reset();
                }

                // use segment if LineWeight is overshooting the center
                if (
                    (
                        OutlineProperties.Type == GeoUtils.OutlineProperties.LineType.Center ||
                        OutlineProperties.Type == GeoUtils.OutlineProperties.LineType.Inner
                    ) &&
                    (
                        radius.x + OutlineProperties.GetInnerDistace() < 0.0f ||
                        radius.y + OutlineProperties.GetInnerDistace() < 0.0f
                    )

                    )
                {
                    if (OutlineProperties.Type == GeoUtils.OutlineProperties.LineType.Center)
                    {
                        radius.x *= 2.0f;
                        radius.y *= 2.0f;
                    }

                    UIShapesKit.Arcs.AddSegment(
                        ref vh,
                        pixelRect.center,
                        radius,
                        EllipseProperties,
                        ArcProperties,
                        ShapeProperties.FillColor,
                        GeoUtils.ZeroV2,
                        ref unitPositionData,
                        edgeGradientData
                        );
                }
                else
                {
                    if (LineProperties.LineCap == UIShapesKit.Lines.LineProperties.LineCapTypes.Close)
                    {
                        UIShapesKit.Arcs.AddArcRing(
                            ref vh,
                            pixelRect.center,
                            radius,
                            EllipseProperties,
                            ArcProperties,
                            OutlineProperties,
                            ShapeProperties.FillColor,
                            GeoUtils.ZeroV2,
                            ref unitPositionData,
                            edgeGradientData
                            );
                    }
                    else
                    {
                        UIShapesKit.Lines.AddLine(
                            ref vh,
                            LineProperties,
                            PointListProperties,
                            pixelRect.center,
                            OutlineProperties,
                            ShapeProperties.FillColor,
                            GeoUtils.ZeroV2,
                            ref PointsData,
                            edgeGradientData
                            );
                    }
                }
            }
        }
예제 #2
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();

            OutlineProperties.UpdateAdjusted();
            ShadowProperties.UpdateAdjusted();

            if (pointsListData == null || pointsListData.Length != PointListsProperties.PointListProperties.Length)
            {
                System.Array.Resize(ref pointsListData, PointListsProperties.PointListProperties.Length);

                for (int i = 0; i < pointsListData.Length; i++)
                {
                    pointsListData[i].NeedsUpdate = true;
                    PointListsProperties.PointListProperties[i].GeneratorData.NeedsUpdate = true;
                }
            }

            for (int i = 0; i < PointListsProperties.PointListProperties.Length; i++)
            {
                PointListsProperties.PointListProperties[i].SetPoints();
            }

            for (int i = 0; i < PointListsProperties.PointListProperties.Length; i++)
            {
                if (
                    PointListsProperties.PointListProperties[i].Positions != null &&
                    PointListsProperties.PointListProperties[i].Positions.Length > 1
                    )
                {
                    AntiAliasingProperties.UpdateAdjusted(canvas);

                    // shadows
                    if (ShadowProperties.ShadowsEnabled)
                    {
                        for (int j = 0; j < ShadowProperties.Shadows.Length; j++)
                        {
                            edgeGradientData.SetActiveData(
                                1.0f - ShadowProperties.Shadows[j].Softness,
                                ShadowProperties.Shadows[j].Size,
                                AntiAliasingProperties.Adjusted
                                );

                            UIShapesKit.Lines.AddLine(
                                ref vh,
                                LineProperties,
                                PointListsProperties.PointListProperties[i],
                                ShadowProperties.GetCenterOffset(GeoUtils.ZeroV2, j),
                                OutlineProperties,
                                ShadowProperties.Shadows[j].Color,
                                GeoUtils.ZeroV2,
                                ref pointsListData[i],
                                edgeGradientData
                                );
                        }
                    }
                }
            }

            for (int i = 0; i < PointListsProperties.PointListProperties.Length; i++)
            {
                if (
                    PointListsProperties.PointListProperties[i].Positions != null &&
                    PointListsProperties.PointListProperties[i].Positions.Length > 1
                    )
                {
                    // fill
                    if (ShadowProperties.ShowShape)
                    {
                        if (AntiAliasingProperties.Adjusted > 0.0f)
                        {
                            edgeGradientData.SetActiveData(
                                1.0f,
                                0.0f,
                                AntiAliasingProperties.Adjusted
                                );
                        }
                        else
                        {
                            edgeGradientData.Reset();
                        }

                        UIShapesKit.Lines.AddLine(
                            ref vh,
                            LineProperties,
                            PointListsProperties.PointListProperties[i],
                            GeoUtils.ZeroV2,
                            OutlineProperties,
                            ShapeProperties.FillColor,
                            GeoUtils.ZeroV2,
                            ref pointsListData[i],
                            edgeGradientData
                            );
                    }
                }
            }
        }
예제 #3
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();

            OutlineProperties.UpdateAdjusted();
            ShadowProperties.UpdateAdjusted();

            Rect pixelRect = RectTransformUtility.PixelAdjustRect(rectTransform, canvas);

            UIShapesKit.Ellipses.SetRadius(
                ref radius,
                pixelRect.width,
                pixelRect.height,
                EllipseProperties
                );

            EllipseProperties.UpdateAdjusted(radius, 0.0f);
            AntiAliasingProperties.UpdateAdjusted(canvas);


            // draw fill shadows
            if (ShadowProperties.ShadowsEnabled)
            {
                if (ShapeProperties.DrawFill && ShapeProperties.DrawFillShadow)
                {
                    for (int i = 0; i < ShadowProperties.Shadows.Length; i++)
                    {
                        edgeGradientData.SetActiveData(
                            1.0f - ShadowProperties.Shadows[i].Softness,
                            ShadowProperties.Shadows[i].Size,
                            AntiAliasingProperties.Adjusted
                            );

                        UIShapesKit.Ellipses.AddCircle(
                            ref vh,
                            ShadowProperties.GetCenterOffset(pixelRect.center, i),
                            radius,
                            EllipseProperties,
                            ShadowProperties.Shadows[i].Color,
                            GeoUtils.ZeroV2,
                            ref unitPositionData,
                            edgeGradientData
                            );
                    }
                }
            }

            if (ShadowProperties.ShowShape && ShapeProperties.DrawFill)
            {
                if (AntiAliasingProperties.Adjusted > 0.0f)
                {
                    edgeGradientData.SetActiveData(
                        1.0f,
                        0.0f,
                        AntiAliasingProperties.Adjusted
                        );
                }
                else
                {
                    edgeGradientData.Reset();
                }

                UIShapesKit.Ellipses.AddCircle(
                    ref vh,
                    (Vector3)pixelRect.center,
                    radius,
                    EllipseProperties,
                    ShapeProperties.FillColor,
                    GeoUtils.ZeroV2,
                    ref unitPositionData,
                    edgeGradientData
                    );
            }

            if (ShadowProperties.ShadowsEnabled)
            {
                // draw outline shadows
                if (ShapeProperties.DrawOutline && ShapeProperties.DrawOutlineShadow)
                {
                    for (int i = 0; i < ShadowProperties.Shadows.Length; i++)
                    {
                        edgeGradientData.SetActiveData(
                            1.0f - ShadowProperties.Shadows[i].Softness,
                            ShadowProperties.Shadows[i].Size,
                            AntiAliasingProperties.Adjusted
                            );

                        UIShapesKit.Ellipses.AddRing(
                            ref vh,
                            ShadowProperties.GetCenterOffset(pixelRect.center, i),
                            radius,
                            OutlineProperties,
                            EllipseProperties,
                            ShadowProperties.Shadows[i].Color,
                            GeoUtils.ZeroV2,
                            ref unitPositionData,
                            edgeGradientData
                            );
                    }
                }
            }


            // fill
            if (ShadowProperties.ShowShape && ShapeProperties.DrawOutline)
            {
                if (AntiAliasingProperties.Adjusted > 0.0f)
                {
                    edgeGradientData.SetActiveData(
                        1.0f,
                        0.0f,
                        AntiAliasingProperties.Adjusted
                        );
                }
                else
                {
                    edgeGradientData.Reset();
                }

                UIShapesKit.Ellipses.AddRing(
                    ref vh,
                    (Vector3)pixelRect.center,
                    radius,
                    OutlineProperties,
                    EllipseProperties,
                    ShapeProperties.OutlineColor,
                    Vector2.zero,
                    ref unitPositionData,
                    edgeGradientData
                    );
            }
        }
예제 #4
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();

            pixelRect = RectTransformUtility.PixelAdjustRect(rectTransform, canvas);

            UIShapesKit.Ellipses.SetRadius(
                ref radius,
                pixelRect.width,
                pixelRect.height,
                EllipseProperties
                );

            EllipseProperties.UpdateAdjusted(radius, 0.0f);
            ArcProperties.UpdateAdjusted(EllipseProperties.AdjustedResolution, EllipseProperties.BaseAngle);
            AntiAliasingProperties.UpdateAdjusted(canvas);
            ShadowProperties.UpdateAdjusted();

            // shadows
            if (ShadowProperties.ShadowsEnabled)
            {
                for (int i = 0; i < ShadowProperties.Shadows.Length; i++)
                {
                    edgeGradientData.SetActiveData(
                        1.0f - ShadowProperties.Shadows[i].Softness,
                        ShadowProperties.Shadows[i].Size,
                        AntiAliasingProperties.Adjusted
                        );

                    UIShapesKit.Arcs.AddSegment(
                        ref vh,
                        ShadowProperties.GetCenterOffset(pixelRect.center, i),
                        radius,
                        EllipseProperties,
                        ArcProperties,
                        ShadowProperties.Shadows[i].Color,
                        GeoUtils.ZeroV2,
                        ref unitPositionData,
                        edgeGradientData
                        );
                }
            }

            // fill
            if (ShadowProperties.ShowShape)
            {
                if (AntiAliasingProperties.Adjusted > 0.0f)
                {
                    edgeGradientData.SetActiveData(
                        1.0f,
                        0.0f,
                        AntiAliasingProperties.Adjusted
                        );
                }
                else
                {
                    edgeGradientData.Reset();
                }

                UIShapesKit.Arcs.AddSegment(
                    ref vh,
                    (Vector3)pixelRect.center,
                    radius,
                    EllipseProperties,
                    ArcProperties,
                    ShapeProperties.FillColor,
                    GeoUtils.ZeroV2,
                    ref unitPositionData,
                    edgeGradientData
                    );
            }
        }
예제 #5
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();

            if (pointsListData == null || pointsListData.Length != PointListsProperties.PointListProperties.Length)
            {
                System.Array.Resize(ref pointsListData, PointListsProperties.PointListProperties.Length);

                for (int i = 0; i < pointsListData.Length; i++)
                {
                    pointsListData[i].NeedsUpdate = true;
                    pointsListData[i].IsClosed    = true;
                }
            }

            pixelRect = RectTransformUtility.PixelAdjustRect(rectTransform, canvas);

            AntiAliasingProperties.UpdateAdjusted(canvas);
            ShadowProperties.UpdateAdjusted();

            for (int i = 0; i < PointListsProperties.PointListProperties.Length; i++)
            {
                PointListsProperties.PointListProperties[i].GeneratorData.SkipLastPosition = true;
                PointListsProperties.PointListProperties[i].SetPoints();
            }

            for (int i = 0; i < PointListsProperties.PointListProperties.Length; i++)
            {
                if (
                    PointListsProperties.PointListProperties[i].Positions != null &&
                    PointListsProperties.PointListProperties[i].Positions.Length > 2
                    )
                {
                    PolygonProperties.UpdateAdjusted(PointListsProperties.PointListProperties[i]);

                    // shadows
                    if (ShadowProperties.ShadowsEnabled)
                    {
                        for (int j = 0; j < ShadowProperties.Shadows.Length; j++)
                        {
                            edgeGradientData.SetActiveData(
                                1.0f - ShadowProperties.Shadows[j].Softness,
                                ShadowProperties.Shadows[j].Size,
                                AntiAliasingProperties.Adjusted
                                );

                            UIShapesKit.Polygons.AddPolygon(
                                ref vh,
                                PolygonProperties,
                                PointListsProperties.PointListProperties[i],
                                ShadowProperties.GetCenterOffset(pixelRect.center, j),
                                ShadowProperties.Shadows[j].Color,
                                GeoUtils.ZeroV2,
                                ref pointsListData[i],
                                edgeGradientData
                                );
                        }
                    }
                }
            }


            for (int i = 0; i < PointListsProperties.PointListProperties.Length; i++)
            {
                if (
                    PointListsProperties.PointListProperties[i].Positions != null &&
                    PointListsProperties.PointListProperties[i].Positions.Length > 2
                    )
                {
                    PolygonProperties.UpdateAdjusted(PointListsProperties.PointListProperties[i]);

                    // fill
                    if (ShadowProperties.ShowShape)
                    {
                        if (AntiAliasingProperties.Adjusted > 0.0f)
                        {
                            edgeGradientData.SetActiveData(
                                1.0f,
                                0.0f,
                                AntiAliasingProperties.Adjusted
                                );
                        }
                        else
                        {
                            edgeGradientData.Reset();
                        }

                        UIShapesKit.Polygons.AddPolygon(
                            ref vh,
                            PolygonProperties,
                            PointListsProperties.PointListProperties[i],
                            pixelRect.center,
                            ShapeProperties.FillColor,
                            GeoUtils.ZeroV2,
                            ref pointsListData[i],
                            edgeGradientData
                            );
                    }
                }
            }
        }