Exemplo n.º 1
0
    internal static Vector3 GetDefaultOutTangent(ShapeData shape, int pointId)
    {
        //TODO: fix all this
        if (shape.GetPolyPointCount() < 2)
        {
            return(Vector3.left);
        }

        if (shape.IsStrokeClosed || pointId < shape.GetPolyPointCount() - 1)
        {
            int otherId = MathUtils.CircularModulo(pointId + 1, shape.GetPolyPointCount());

            if (shape.GetPolyPointType(otherId) == ShapePointType.Corner)
            {
                return((shape.GetPolyPosition(otherId) - shape.GetPolyPosition(pointId)) * .333f);
            }
            else
            {
                return((shape.GetPolyPosition(otherId) + shape.GetPolyOutTangent(otherId) - shape.GetPolyPosition(pointId)) * .333f);
            }
        }
        else
        {
            return(-(shape.GetPolyPosition(pointId - 1) - shape.GetPolyPosition(pointId)) * .333f);
        }
    }
Exemplo n.º 2
0
        public static ShapeVertexInfo GetPolyVertexInfo(ShapeData shape, int pointId)
        {
            int pointCount = shape.GetPolyPointCount();

            if (pointCount == 0)
            {
                return(new ShapeVertexInfo());
            }

            if (pointId >= 0 && pointId < pointCount)
            {
                return(GetVertexInfoInRange(shape, pointId));
            }

            if (shape.IsStrokeClosed)
            {
                pointId = MathUtils.CircularModulo(pointId, pointCount);
                return(GetVertexInfoInRange(shape, pointId));
            }
            else
            {
                if (pointId < 0)
                {
                    ShapeVertexInfo vertex = GetVertexInfoInRange(shape, 0);

                    if (shape.GetPolyPointType(0) == ShapePointType.Corner)
                    {
                        vertex.position += shape.GetPolyPosition(0) - (shape.GetPolyPosition(1) + shape.GetPolyInTangent(1));
                    }
                    else
                    {
                        vertex.position += -shape.GetPolyOutTangent(0);
                    }
                    return(vertex);
                }
                else
                {
                    ShapeVertexInfo vertex = GetVertexInfoInRange(shape, pointCount - 1);

                    if (shape.GetPolyPointType(pointCount - 1) == ShapePointType.Corner)
                    {
                        vertex.position += shape.GetPolyPosition(pointCount - 1) - (shape.GetPolyPosition(pointCount - 2) + shape.GetPolyOutTangent(pointCount - 2));                            // create new point as extension of existing line
                    }
                    else
                    {
                        vertex.position += -shape.GetPolyInTangent(pointCount - 1);
                    }
                    return(vertex);
                }
            }
        }
Exemplo n.º 3
0
        public static ShapeVertexInfo GetVertexInfoInRange(ShapeData shape, int pointId)
        {
            ShapeVertexInfo vertex = new ShapeVertexInfo();

            vertex.position    = shape.GetPolyPosition(pointId);
            vertex.inTangent   = shape.GetPolyInTangent(pointId);
            vertex.outTangent  = shape.GetPolyOutTangent(pointId);
            vertex.strokeColor = shape.GetPolyStrokeColor(pointId);
            vertex.strokeWidth = shape.GetPolyStrokeWidth(pointId);
            vertex.type        = shape.GetPolyPointType(pointId);
            return(vertex);
        }