private void RenderRectElement(SVGRectElement rectElement, ISVGPathDraw pathDraw) { SVGPoint p1, p2, p3, p4; float tx = rectElement.x.value; float ty = rectElement.y.value; float tw = rectElement.width.value; float th = rectElement.height.value; p1 = new SVGPoint(tx, ty); p2 = new SVGPoint(tx + tw, ty); p3 = new SVGPoint(tx + tw, ty + th); p4 = new SVGPoint(tx, ty + th); if(rectElement.rx.value == 0.0f && rectElement.ry.value == 0.0f) { p1 = p1.MatrixTransform(matrixTransform); p2 = p2.MatrixTransform(matrixTransform); p3 = p3.MatrixTransform(matrixTransform); p4 = p4.MatrixTransform(matrixTransform); pathDraw.Rect(p1, p2, p3, p4); } else { float t_rx = rectElement.rx.value; float t_ry = rectElement.ry.value; t_rx = (t_rx == 0.0f) ? t_ry : t_rx; t_ry = (t_ry == 0.0f) ? t_rx : t_ry; t_rx = (t_rx > (tw * 0.5f - 2f)) ? (tw * 0.5f - 2f) : t_rx; t_ry = (t_ry > (th * 0.5f - 2f)) ? (th * 0.5f - 2f) : t_ry; float angle = transformAngle; SVGPoint t_p1 = new SVGPoint(p1.x + t_rx, p1.y).MatrixTransform(matrixTransform); SVGPoint t_p2 = new SVGPoint(p2.x - t_rx, p2.y).MatrixTransform(matrixTransform); SVGPoint t_p3 = new SVGPoint(p2.x, p2.y + t_ry).MatrixTransform(matrixTransform); SVGPoint t_p4 = new SVGPoint(p3.x, p3.y - t_ry).MatrixTransform(matrixTransform); SVGPoint t_p5 = new SVGPoint(p3.x - t_rx, p3.y).MatrixTransform(matrixTransform); SVGPoint t_p6 = new SVGPoint(p4.x + t_rx, p4.y).MatrixTransform(matrixTransform); SVGPoint t_p7 = new SVGPoint(p4.x, p4.y - t_ry).MatrixTransform(matrixTransform); SVGPoint t_p8 = new SVGPoint(p1.x, p1.y + t_ry).MatrixTransform(matrixTransform); pathDraw.RoundedRect(t_p1, t_p2, t_p3, t_p4, t_p5, t_p6, t_p7, t_p8, t_rx, t_ry, angle); } }
private void RenderMoveTo(SVGPoint p, ISVGPathDraw pathDraw) { pathDraw.MoveTo(p.MatrixTransform(matrixTransform)); }
//----- private void SetGradientVector(SVGGraphicsPath graphicsPath) { SVGRect bound = graphicsPath.GetBound(); if(_linearGradElement.x1.unitType == SVGLengthType.Percentage) { _x1 = bound.x + (bound.width * _x1 / 100f); } if(_linearGradElement.y1.unitType == SVGLengthType.Percentage) { _y1 = bound.y + (bound.height * _y1 / 100f); } if(_linearGradElement.x2.unitType == SVGLengthType.Percentage) { _x2 = bound.x + (bound.width * _x2 / 100f); } if(_linearGradElement.y2.unitType == SVGLengthType.Percentage) { _y2 = bound.y + (bound.height * _y2 / 100f); } if(_linearGradElement.gradientUnits == SVGGradientUnit.ObjectBoundingBox) { SVGPoint _point = new SVGPoint(_x1, _y1); _point = _point.MatrixTransform(graphicsPath.matrixTransform); _x1 = _point.x; _y1 = _point.y; _point = new SVGPoint(_x2, _y2); _point = _point.MatrixTransform(graphicsPath.matrixTransform); _x2 = _point.x; _y2 = _point.y; } }
public void Render() { SVGPoint p1, p2; SVGMatrix _matrix = this.transformMatrix; if(this._paintable.strokeColor == null)return; float _width = this._paintable.strokeWidth; this._render.SetStrokeLineCap(this._paintable.strokeLineCap); float tx1 = this._x1.value; float ty1 = this._y1.value; float tx2 = this._x2.value; float ty2 = this._y2.value; p1 = new SVGPoint(tx1, ty1); p2 = new SVGPoint(tx2, ty2); p1 = p1.MatrixTransform(_matrix); p2 = p2.MatrixTransform(_matrix); this._render.Line(p1, p2, this._paintable.strokeColor, _width); }
//----- private void SetGradientVector(SVGGraphicsPath graphicsPath) { SVGRect bound = graphicsPath.GetBound(); if(_radialGradElement.cx.unitType == SVGLengthType.Percentage) { _cx = bound.x + (bound.width * _cx / 100f); } if(_radialGradElement.cy.unitType == SVGLengthType.Percentage) { _cy = bound.y + (bound.height * _cy / 100f); } if(_radialGradElement.r.unitType == SVGLengthType.Percentage) { SVGPoint _p1 = new SVGPoint(bound.x, bound.y); SVGPoint _p2 = new SVGPoint(bound.x + bound.width, bound.y + bound.height); _p1 = _p1.MatrixTransform(graphicsPath.matrixTransform); _p2 = _p2.MatrixTransform(graphicsPath.matrixTransform); float dd = (float)Math.Sqrt((_p2.x - _p1.x) * (_p2.x - _p1.x) + (_p2.y - _p1.y) * (_p2.y - _p1.y)); _r = (dd * _r / 100f); } if(_radialGradElement.fx.unitType == SVGLengthType.Percentage) { _fx = bound.x + (bound.width * _fx / 100f); } if(_radialGradElement.fy.unitType == SVGLengthType.Percentage) { _fy = bound.y + (bound.height * _fy / 100f); } if((float)Math.Sqrt((_cx - _fx) * (_cx - _fx) + (_cy - _fy) * (_cy - _fy)) > _r) { SVGPoint _cP = CrossPoint(_cx, _cy); _fx = _cP.x; _fy = _cP.y; } if(_radialGradElement.gradientUnits == SVGGradientUnit.ObjectBoundingBox) { SVGPoint _point = new SVGPoint(_cx, _cy); _point = _point.MatrixTransform(graphicsPath.matrixTransform); _cx = _point.x; _cy = _point.y; _point = new SVGPoint(_fx, _fy); _point = _point.MatrixTransform(graphicsPath.matrixTransform); _fx = _point.x; _fy = _point.y; } }