/// <summary> /// Create the inner polygon of the doughnut. /// </summary> /// <param name="_value">double</param> /// <param name="_sumDegree">double</param> /// <param name="_color">Color</param> /// <param name="_degree">double</param> private void CreateInnerSection(double _value, ref double _sumDegree, Color _color, out double _degree) { SVGPoint p1 = null, p2 = null; Polygon pol = null; ArrayList points = null; _degree = this.Relation * _value; if (_sumDegree >= 270 || _sumDegree <= 90 || _degree + _sumDegree >= 270 || _degree + _sumDegree <= 90) { pol = new Polygon(); pol.Color = _color; points = new ArrayList(); double k = _sumDegree; while (k < _degree + _sumDegree) { p1 = this.GetPoint(k, this.a2, this.b2); pol.AddPoint(p1); p2 = p1; p2.Y += THICKNESS; points.Insert(0, p2); k += 0.2; } foreach (SVGPoint point in points) { pol.AddPoint(point); } this.Doc.SvgObjects.Add(pol); } _sumDegree += _degree; }
/// <summary> /// Creates new point and adds it into collection /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <returns></returns> public SVGPoint Add(Int32 x, Int32 y) { SVGPoint p = new SVGPoint(x, y); points.Add(p); return(p); }
//-------------------------------------------------------------------------------- //Methods: ArcTo //-------------------------------------------------------------------------------- public void ArcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPoint p) { if((this.isUseWidth) && ((int)this._width > 1)) ArcTo(r1, r2, angle, largeArcFlag, sweepFlag, p, this._width); else this._basicDraw.ArcTo(r1, r2, angle, largeArcFlag, sweepFlag, p); }
//----- public void Circle(SVGPoint p, float r, SVGColor? strokeColor) { if(strokeColor != null) { SetColor(strokeColor.Value.color); } Circle(p, r); }
public SVGGEllipse(SVGPoint p, float r1, float r2, float angle) { _p = p; _r1 = r1; _r2 = r2; _angle = angle; }
/*------------------------------------------------------------------------------- //Method: Arc4Path /-------------------------------------------------------------------------------*/ public void ArcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPoint p) { SVGPoint[] points = new SVGPoint[1]; points[0] = p; ExpandBounds(points, (r1 > r2) ? 2 * (int)r1 + 2 : 2 * (int)r2 + 2, (r1 > r2) ? 2 * (int)r1 + 2 : 2 * (int)r2 + 2); //--------------- this._basicDraw.ArcTo(r1, r2, angle, largeArcFlag, sweepFlag, p); }
/// <summary> /// Returns a point in the area depending of the angle's degree and the height. /// </summary> /// <param name="_degree">double</param> /// <param name="_height">double</param> /// <returns>SVGPoint</returns> protected virtual SVGPoint GetPoint(double _degree, double _height) { SVGPoint p = new SVGPoint(); double rad = this.GetRadians(_degree); p.X = Math.Sin(rad) * _height + this.CenterPos.X; p.Y = this.CenterPos.Y - Math.Cos(rad) * _height; return(p); }
/// <summary> /// Creates a line with two points of the collection /// </summary> /// <param name="_source">SVGPoint</param> /// <param name="_target">SVGPoint</param> protected void CreateLine(SVGPoint _source, SVGPoint _target) { Line line = new Line(_source, _target); line.Width = (decimal)0.5; line.Color = System.Drawing.Color.Black; line.Dashed = false; this.Doc.SvgObjects.Add(line); }
//================================================================================ public SVGGArcAbs(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPoint p) { this._r1 = r1; this._r2 = r2; this._angle = angle; this._largeArcFlag = largeArcFlag; this._sweepFlag = sweepFlag; this._p = p; }
public SVGGraphicsPath() { beginPoint = new SVGPoint(0f, 0f); endPoint = new SVGPoint(0f, 0f); needSetFirstPoint = true; boundUL = new SVGPoint(+10000f, +10000f); boundBR = new SVGPoint(-10000f, -10000f); transformList = new SVGTransformList(); listObject = new ArrayList(); listType = new ArrayList(); }
//-------------------------------------------------------------------------------- //AngleBetween2Vector //-------------------------------------------------------------------------------- //Tinh goc giua 2 vector (p1,p2) (p3,p4); public float AngleBetween2Vector(SVGPoint p1, SVGPoint p2, SVGPoint p3, SVGPoint p4) { SVGPoint vt1, vt2; vt1 = new SVGPoint(p2.x - p1.x, p2.y - p1.y); vt2 = new SVGPoint(p4.x - p3.x, p4.y - p3.y); float t1 = vt1.x*vt2.x + vt1.y*vt2.y; float gtvt1 = (float)Math.Sqrt(vt1.x * vt1.x + vt1.y*vt1.y); float gtvt2 = (float)Math.Sqrt(vt2.x * vt2.x + vt2.y*vt2.y); float t2 = gtvt1 * gtvt2; float cosAngle = t1/t2; return((float)Math.Acos(cosAngle)); }
/// <summary> /// Get a value's point /// </summary> /// <param name="_value">double</param> /// <param name="_xStartPosition">double</param> /// <param name="_yStartPosition">double</param> /// <returns>SVGPoint</returns> private SVGPoint GeneratePoint(double _value, double _xStartPosition, double _yStartPosition) { double pixelValue = _value - this.minFillFactor; pixelValue = pixelValue / (this.maxFillFactor - this.minFillFactor); pixelValue = pixelValue * 100 * this.tpcmaxFillFactor; SVGPoint p1 = new SVGPoint(); p1.X = _xStartPosition + (this.colWidth / 2); p1.Y = _yStartPosition + pixelValue; return(p1); }
public void BeginSubBuffer() { this._boundTopLeft = new SVGPoint(+10000f, +10000f); this._boundBottomRight = new SVGPoint(-10000f, -10000f); this._subW = this._width; this._subH = this._height; this._inZoneL = 0; this._inZoneT = 0; this._translateX = 0; this._translateY = 0; this._flagStep = 0; for(int i = 0; i < this._subW; i++) for(int j = 0; j < this._subH; j++) this._flag[i, j] = 0; this._flagStep = 1; }
/// <summary> /// Gets the point from string. /// </summary> /// <param name="input">The input.</param> /// <returns></returns> public static SVGPoint GetPointFromString(this String input) { foreach (Match m in REGEX_POINT_PAIR.Matches(input)) { if (m.Success) { if (m.Groups.Count > 2) { SVGPoint p = new SVGPoint(); p.X = Convert.ToDouble(m.Groups[2]); p.Y = Convert.ToDouble(m.Groups[3]); return(p); } } } throw new ArgumentException("input string is not in required format", "input"); return(null); }
/// <summary> /// Creates the polygon's value. /// </summary> /// <param name="_value">double</param> /// <param name="_sumDegree">double</param> /// <param name="_color">Color</param> /// <param name="_degree">double</param> protected override void CreateCheese(double _value, ref double _sumDegree, Color _color, out double _degree) { Polygon pol = new Polygon(); pol.Color = _color; _degree = this.Relation * _value; //1st Segment SVGPoint p1 = this.GetPoint(_sumDegree); SVGPoint p1_2 = this.GetPoint(_sumDegree, this.secRadio); pol.AddPoint(p1_2); pol.AddPoint(p1); //Curve double k = _sumDegree; while (k < _degree + _sumDegree) { pol.AddPoint(this.GetPoint(k)); k += 0.2; } //2th Segment _sumDegree += _degree; SVGPoint p2 = this.GetPoint(_sumDegree); SVGPoint p2_2 = this.GetPoint(_sumDegree, this.secRadio); pol.AddPoint(p2_2); pol.AddPoint(p2); //Curve k = _sumDegree; while (k > _sumDegree - _degree) { pol.AddPoint(this.GetPoint(k, this.secRadio)); k -= 0.2; } this.Doc.SvgObjects.Add(pol); }
/// <summary> /// Gets points from string: x1,y1 x2,y2 x3,y3 .... where xn,yn are coordinates of point n /// </summary> /// <param name="input">The input.</param> /// <returns></returns> public static List <SVGPoint> GetPointsFromString(this String input) { List <SVGPoint> output = new List <SVGPoint>(); foreach (Match m in REGEX_POINT_PAIR.Matches(input)) { if (m.Success) { if (m.Groups.Count > 2) { SVGPoint p = new SVGPoint(); p.X = Convert.ToDouble(m.Groups[2]); p.Y = Convert.ToDouble(m.Groups[3]); output.Add(p); } } } return(output); }
private void ExpandBounds(SVGPoint point, float deltax, float deltay) { ExpandBounds(point.x, point.y, deltax, deltay); }
public void Reset() { beginPoint = new SVGPoint(0f, 0f); endPoint = new SVGPoint(0f, 0f); needSetFirstPoint = true; boundUL = new SVGPoint(+10000f, +10000f); boundBR = new SVGPoint(-10000f, -10000f); _fillRule = SVGFillRule.NoneZero; transformList.Clear(); listObject.Clear(); listType.Clear(); }
private void ExpandBounds(SVGPoint point) { ExpandBounds(point.x, point.y); }
//----- public void Circle(SVGPoint p, float r, SVGColor fillColor, SVGColor? strokeColor) { SetColor(fillColor.color); PreCircle(p, r); EndSubBuffer(); }
public void AddQuadraticCurveTo(SVGPoint p1, SVGPoint p) { SetLastPoint(p); SVGGQuadraticAbs svgGQuadraticAbs = new SVGGQuadraticAbs(p1, p); listType.Add(SVGPathElementType.QuadraticCurveTo); listObject.Add(svgGQuadraticAbs); }
/// <summary> /// Add the value's point /// </summary> /// <param name="_point">SVGObject.point</param> public void AddPoint(SVGPoint _point) { Array.Resize(ref this.points, this.points.Length + 1); this.points[this.points.Length - 1] = _point; }
private void RenderPolylineElement(SVGPolylineElement polylineElement, ISVGPathDraw pathDraw) { int length = polylineElement.listPoints.Count; SVGPoint[] points = new SVGPoint[length]; for(int i = 0; i < length; i++) points[i] = polylineElement.listPoints[i].MatrixTransform(matrixTransform); pathDraw.Polyline(points); }
public void AddCircleTo(SVGPoint p, float r) { SVGGCircle gCircle = new SVGGCircle(p, r); listType.Add(SVGPathElementType.CircleTo); listObject.Add(gCircle); }
public void AddCubicCurveTo(SVGPoint p1, SVGPoint p2, SVGPoint p) { SetLastPoint(p); SVGGCubicAbs svgGCubicAbs = new SVGGCubicAbs(p1, p2, p); listType.Add(SVGPathElementType.CubicCurveTo); listObject.Add(svgGCubicAbs); }
public void Add(SVGEllipseElement ellipseElement) { SVGPoint p = new SVGPoint(ellipseElement.cx.value, ellipseElement.cy.value); SetFirstPoint(p); SetLastPoint(p); listType.Add(SVGPathElementType.Ellipse); listObject.Add(ellipseElement); }
public void AddArcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPoint p) { SetLastPoint(p); SVGGArcAbs svgGArcAbs = new SVGGArcAbs(r1, r2, angle, largeArcFlag, sweepFlag, p); listType.Add(SVGPathElementType.ArcTo); listObject.Add(svgGArcAbs); }
public svgLine(Int32 x1, Int32 y1, Int32 x2, Int32 y2) { start = new SVGPoint(x1, y1); end = new SVGPoint(x2, y2); }
private void SetFirstPoint(SVGPoint p) { if(needSetFirstPoint) { beginPoint.SetValue(p); needSetFirstPoint = false; } }
//----- public void Circle(SVGPoint p, float r) { PreCircle(p, r); EndSubBuffer(); }
private void RenderCircleElement(SVGCircleElement elem, ISVGPathDraw pathDraw) { SVGPoint p = new SVGPoint(elem.cx.value, elem.cy.value).MatrixTransform(matrixTransform); pathDraw.Circle(p, elem.r.value); }
public void AddEllipseTo(SVGPoint p, float r1, float r2, float angle) { SVGGEllipse gEllipse = new SVGGEllipse(p, r1, r2, angle); listType.Add(SVGPathElementType.EllipseTo); listObject.Add(gEllipse); }
private void RenderEllipseElement(SVGEllipseElement elem, ISVGPathDraw pathDraw) { SVGPoint p = new SVGPoint(elem.cx.value, elem.cy.value).MatrixTransform(matrixTransform); pathDraw.Ellipse(p, elem.rx.value, elem.ry.value, transformAngle); }
public void AddLineTo(SVGPoint p) { listType.Add(SVGPathElementType.LineTo); listObject.Add(p); }
private void RenderMoveTo(SVGPoint p, ISVGPathDraw pathDraw) { pathDraw.MoveTo(p.MatrixTransform(matrixTransform)); }
public void AddMoveTo(SVGPoint p) { SetFirstPoint(p); SetLastPoint(p); listType.Add(SVGPathElementType.MoveTo); listObject.Add(p); }
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); } }
//----- public void Circle(SVGPoint p, float r, SVGColor? strokeColor) { PreCircle(p, r); EndSubBuffer(strokeColor); }
private void SetLastPoint(SVGPoint p) { endPoint.SetValue(p); }
public void Add(SVGCircleElement circleElement) { SVGPoint p = new SVGPoint(circleElement.cx.value, circleElement.cy.value); SetFirstPoint(p); SetLastPoint(p); listType.Add(SVGPathElementType.Circle); listObject.Add(circleElement); }