public static void Parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint, string text) { float?X = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X); float?Y = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y); float?size = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_SIZE); Paint pPaint = pSVGPaint.getPaint(); float fontsize = pPaint.TextSize; if (size != null) { fontsize = (float)size; pPaint = new Paint();// pPaint); pPaint.TextSize = fontsize; } if (X != null && Y != null) { bool fill = pSVGPaint.setFill(pSVGProperties); bool stroke = pSVGPaint.setStroke(pSVGProperties); // ширина текста float width = pPaint.MeasureText(text); pCanvas.DrawText(text, X.Value, Y.Value, pPaint); if (fill || stroke) { pSVGPaint.ensureComputedBoundsInclude(X.Value + width, Y.Value + pPaint.TextSize); } } }
public static void Parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint) { float?centerX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_X); float?centerY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_Y); float?radius = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS); if (centerX != null && centerY != null && radius != null) { bool fill = pSVGPaint.setFill(pSVGProperties); if (fill) { pCanvas.DrawCircle(centerX.Value, centerY.Value, radius.Value, pSVGPaint.getPaint()); } bool stroke = pSVGPaint.setStroke(pSVGProperties); if (stroke) { pCanvas.DrawCircle(centerX.Value, centerY.Value, radius.Value, pSVGPaint.getPaint()); } if (fill || stroke) { pSVGPaint.ensureComputedBoundsInclude(centerX.Value - radius.Value, centerY.Value - radius.Value); pSVGPaint.ensureComputedBoundsInclude(centerX.Value + radius.Value, centerY.Value + radius.Value); } } }
public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint, RectF pRect) { float? centerX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_X); float? centerY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_Y); float? radiusX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_X); float? radiusY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_Y); if (centerX != null && centerY != null && radiusX != null && radiusY != null) { pRect.Set(centerX.Value - radiusX.Value, centerY.Value - radiusY.Value, centerX.Value + radiusX.Value, centerY.Value + radiusY.Value); bool fill = pSVGPaint.setFill(pSVGProperties); if (fill) { pCanvas.DrawOval(pRect, pSVGPaint.getPaint()); } bool stroke = pSVGPaint.setStroke(pSVGProperties); if (stroke) { pCanvas.DrawOval(pRect, pSVGPaint.getPaint()); } if(fill || stroke) { pSVGPaint.ensureComputedBoundsInclude(centerX.Value - radiusX.Value, centerY.Value - radiusY.Value); pSVGPaint.ensureComputedBoundsInclude(centerX.Value + radiusX.Value, centerY.Value + radiusY.Value); } } }
public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint) { float x1 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X1, 0f); float x2 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X2, 0f); float y1 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y1, 0f); float y2 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y2, 0f); if (pSVGPaint.setStroke(pSVGProperties)) { pSVGPaint.ensureComputedBoundsInclude(x1, y1); pSVGPaint.ensureComputedBoundsInclude(x2, y2); pCanvas.DrawLine(x1, y1, x2, y2, pSVGPaint.getPaint()); } }
public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint, RectF pRect) { float x = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X, 0f); float y = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y, 0f); float width = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_WIDTH, 0f); float height = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_HEIGHT, 0f); pRect.Set(x, y, x + width, y + height); float? rX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_X); float? rY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_Y); bool rXSpecified = rX != null && rX >= 0; bool rYSpecified = rY != null && rY >= 0; bool rounded = rXSpecified || rYSpecified; float rx; float ry; if(rXSpecified && rYSpecified) { rx = Math.Min(rX.Value, width * 0.5f); ry = Math.Min(rY.Value, height * 0.5f); } else if(rXSpecified) { ry = rx = Math.Min(rX.Value, width * 0.5f); } else if(rYSpecified) { rx = ry = Math.Min(rY.Value, height * 0.5f); } else { rx = 0; ry = 0; } bool fill = pSVGPaint.setFill(pSVGProperties); if (fill) { if(rounded) { pCanvas.DrawRoundRect(pRect, rx, ry, pSVGPaint.getPaint()); } else { pCanvas.DrawRect(pRect, pSVGPaint.getPaint()); } } bool stroke = pSVGPaint.setStroke(pSVGProperties); if (stroke) { if(rounded) { pCanvas.DrawRoundRect(pRect, rx, ry, pSVGPaint.getPaint()); } else { pCanvas.DrawRect(pRect, pSVGPaint.getPaint()); } } if(fill || stroke) { pSVGPaint.ensureComputedBoundsInclude(x, y, width, height); } }
public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint, RectF pRect) { float x = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X, 0f); float y = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y, 0f); float width = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_WIDTH, 0f); float height = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_HEIGHT, 0f); pRect.Set(x, y, x + width, y + height); float?rX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_X); float?rY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_Y); bool rXSpecified = rX != null && rX >= 0; bool rYSpecified = rY != null && rY >= 0; bool rounded = rXSpecified || rYSpecified; float rx; float ry; if (rXSpecified && rYSpecified) { rx = Math.Min(rX.Value, width * 0.5f); ry = Math.Min(rY.Value, height * 0.5f); } else if (rXSpecified) { ry = rx = Math.Min(rX.Value, width * 0.5f); } else if (rYSpecified) { rx = ry = Math.Min(rY.Value, height * 0.5f); } else { rx = 0; ry = 0; } bool fill = pSVGPaint.setFill(pSVGProperties); if (fill) { if (rounded) { pCanvas.DrawRoundRect(pRect, rx, ry, pSVGPaint.getPaint()); } else { pCanvas.DrawRect(pRect, pSVGPaint.getPaint()); } } bool stroke = pSVGPaint.setStroke(pSVGProperties); if (stroke) { if (rounded) { pCanvas.DrawRoundRect(pRect, rx, ry, pSVGPaint.getPaint()); } else { pCanvas.DrawRect(pRect, pSVGPaint.getPaint()); } } if (fill || stroke) { pSVGPaint.ensureComputedBoundsInclude(x, y, width, height); } }