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); }
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); } } }