Exemplo n.º 1
0
        #pragma warning restore 612, 618

        private static void TessellateShape(Shape vectorShape, List <Geometry> geoms, TessellationOptions tessellationOptions, bool isConvex)
        {
            UnityEngine.Profiling.Profiler.BeginSample("TessellateShape");

            // Don't generate any geometry for pattern fills since these are generated from another SceneNode
            if (vectorShape.Fill != null && !(vectorShape.Fill is PatternFill))
            {
                Color shapeColor = Color.white;
                if (vectorShape.Fill is SolidFill)
                {
                    shapeColor = ((SolidFill)vectorShape.Fill).Color;
                }

                shapeColor.a *= vectorShape.Fill.Opacity;

                if (isConvex && vectorShape.Contours.Length == 1)
                {
                    TessellateConvexContour(vectorShape, vectorShape.PathProps.Stroke, shapeColor, geoms, tessellationOptions);
                }
                else
                {
                    TessellateShapeLibTess(vectorShape, shapeColor, geoms, tessellationOptions);
                }
            }

            var stroke = vectorShape.PathProps.Stroke;

            if (stroke != null && stroke.HalfThickness > VectorUtils.Epsilon)
            {
                var   strokeFill  = stroke.Fill;
                Color strokeColor = Color.white;
                if (strokeFill is SolidFill)
                {
                    strokeColor = ((SolidFill)strokeFill).Color;
                    strokeFill  = null;
                }

                foreach (var c in vectorShape.Contours)
                {
                    Vector2[] strokeVerts;
                    UInt16[]  strokeIndices;
                    VectorUtils.TessellatePath(c, vectorShape.PathProps, tessellationOptions, out strokeVerts, out strokeIndices);
                    if (strokeIndices.Length > 0)
                    {
                        geoms.Add(new Geometry()
                        {
                            Vertices = strokeVerts, Indices = strokeIndices, Color = strokeColor, Fill = strokeFill, FillTransform = stroke.FillTransform
                        });
                    }
                }
            }

            UnityEngine.Profiling.Profiler.EndSample();
        }
Exemplo n.º 2
0
        private static void TessellatePath(BezierContour contour, PathProperties pathProps, List <Geometry> geoms, TessellationOptions tessellationOptions)
        {
            UnityEngine.Profiling.Profiler.BeginSample("TessellatePath");

            if (pathProps.Stroke != null)
            {
                Vector2[] vertices;
                UInt16[]  indices;
                VectorUtils.TessellatePath(contour, pathProps, tessellationOptions, out vertices, out indices);

                var color = pathProps.Stroke.Color;
                if (indices.Length > 0)
                {
                    geoms.Add(new Geometry()
                    {
                        Vertices = vertices, Indices = indices, Color = color
                    });
                }
            }

            UnityEngine.Profiling.Profiler.EndSample();
        }