public AddLineTo ( double x, double y ) : void | ||
x | double | |
y | double | |
return | void |
void CreateEndLineCap(VertexStore outputVxs, Vector v0, Vector v1, double edgeWidth) { switch (this.LineCapStyle) { default: throw new NotSupportedException(); case LineCap.Butt: outputVxs.AddLineTo(v0.X, v0.Y); outputVxs.AddLineTo(v1.X, v1.Y); break; case LineCap.Square: { Vector delta = (v1 - v0).Rotate(90).NewLength(edgeWidth); outputVxs.AddLineTo(v0.X + delta.X, v0.Y + delta.Y); outputVxs.AddLineTo(v1.X + delta.X, v1.Y + delta.Y); } break; case LineCap.Round: { capVectors.Clear(); BuildEndCap(v0.X, v0.Y, v1.X, v1.Y, capVectors); int j = capVectors.Count; for (int i = j - 1; i >= 0; --i) { Vector v = capVectors[i]; outputVxs.AddLineTo(v.X, v.Y); } } break; } }
static Affine BuildImageBoundsPath(int srcW, int srcH, VertexStore drawImageRectPath, AffinePlan[] affPlans) { drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return(Affine.NewMatix(affPlans)); }
static Affine BuildImageBoundsPath(int srcW, int srcH, AffinePlan[] affPlans, VertexStore outputDestImgRect) { outputDestImgRect.Clear(); outputDestImgRect.AddMoveTo(0, 0); outputDestImgRect.AddLineTo(srcW, 0); outputDestImgRect.AddLineTo(srcW, srcH); outputDestImgRect.AddLineTo(0, srcH); outputDestImgRect.AddCloseFigure(); return(Affine.NewMatix(affPlans)); }
Affine BuildImageBoundsPath(IImageReaderWriter sourceImage, VertexStore drawImageRectPath, AffinePlan[] affPlans) { int srcW = sourceImage.Width; int srcH = sourceImage.Height; drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return(Affine.NewMatix(affPlans)); }
Affine BuildImageBoundsPath(IImageReaderWriter sourceImage, VertexStore drawImageRectPath, double destX, double destY, double hotspotOffsetX, double hotSpotOffsetY, double scaleX, double scaleY, double angleRad) { AffinePlan[] plan = new AffinePlan[4]; int i = 0; if (hotspotOffsetX != 0.0f || hotSpotOffsetY != 0.0f) { plan[i] = AffinePlan.Translate(-hotspotOffsetX, -hotSpotOffsetY); i++; } if (scaleX != 1 || scaleY != 1) { plan[i] = AffinePlan.Scale(scaleX, scaleY); i++; } if (angleRad != 0) { plan[i] = AffinePlan.Rotate(angleRad); i++; } if (destX != 0 || destY != 0) { plan[i] = AffinePlan.Translate(destX, destY); i++; } int srcW = sourceImage.Width; int srcH = sourceImage.Height; drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return(Affine.NewMatix(plan)); }
public void dbugLine(double x1, double y1, double x2, double y2, ColorRGBA color) { VertexStore vxs = new VertexStore(8); vxs.AddMoveTo(x1, y1); vxs.AddLineTo(x2, y2); vxs.AddStop(); Render(new Stroke(1).MakeVxs(vxs), color); }
static Affine BuildImageBoundsPath( int srcW, int srcH, double destX, double destY, VertexStore outputDestImgRect) { AffinePlan plan = new AffinePlan(); if (destX != 0 || destY != 0) { plan = AffinePlan.Translate(destX, destY); } outputDestImgRect.Clear(); outputDestImgRect.AddMoveTo(0, 0); outputDestImgRect.AddLineTo(srcW, 0); outputDestImgRect.AddLineTo(srcW, srcH); outputDestImgRect.AddLineTo(0, srcH); outputDestImgRect.AddCloseFigure(); return(Affine.NewMatix(plan)); }
static Affine BuildImageBoundsPath( int srcW, int srcH, double destX, double destY, double hotspotOffsetX, double hotSpotOffsetY, double scaleX, double scaleY, double angleRad, VertexStore outputDestImgRect) { AffinePlan[] plans = new AffinePlan[4]; int i = 0; if (hotspotOffsetX != 0.0f || hotSpotOffsetY != 0.0f) { plans[i] = AffinePlan.Translate(-hotspotOffsetX, -hotSpotOffsetY); i++; } if (scaleX != 1 || scaleY != 1) { plans[i] = AffinePlan.Scale(scaleX, scaleY); i++; } if (angleRad != 0) { plans[i] = AffinePlan.Rotate(angleRad); i++; } if (destX != 0 || destY != 0) { plans[i] = AffinePlan.Translate(destX, destY); i++; } outputDestImgRect.Clear(); outputDestImgRect.AddMoveTo(0, 0); outputDestImgRect.AddLineTo(srcW, 0); outputDestImgRect.AddLineTo(srcW, srcH); outputDestImgRect.AddLineTo(0, srcH); outputDestImgRect.AddCloseFigure(); return(Affine.NewMatix(plans)); }
public static void CreateBezierVxs4(VertexStore vxs, Vector2 start, Vector2 end, Vector2 control1, Vector2 control2) { var curve = new VectorMath.BezierCurveCubic( start, end, control1, control2); vxs.AddLineTo(start.x, start.y); float eachstep = (float)1 / NSteps; float stepSum = eachstep;//start for (int i = 1; i < NSteps; ++i) { var vector2 = curve.CalculatePoint(stepSum); vxs.AddLineTo(vector2.x, vector2.y); stepSum += eachstep; } vxs.AddLineTo(end.x, end.y); }
Affine BuildImageBoundsPath( int srcW, int srcH, VertexStore drawImageRectPath, double destX, double destY, double hotspotOffsetX, double hotSpotOffsetY, double scaleX, double scaleY, double angleRad) { AffinePlan[] plan = new AffinePlan[4]; int i = 0; if (hotspotOffsetX != 0.0f || hotSpotOffsetY != 0.0f) { plan[i] = AffinePlan.Translate(-hotspotOffsetX, -hotSpotOffsetY); i++; } if (scaleX != 1 || scaleY != 1) { plan[i] = AffinePlan.Scale(scaleX, scaleY); i++; } if (angleRad != 0) { plan[i] = AffinePlan.Rotate(angleRad); i++; } if (destX != 0 || destY != 0) { plan[i] = AffinePlan.Translate(destX, destY); i++; } drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return Affine.NewMatix(plan); }
public void dbugLine(double x1, double y1, double x2, double y2, Drawing.Color color) { dbug_v1.AddMoveTo(x1, y1); dbug_v1.AddLineTo(x2, y2); //dbug_v1.AddStop(); dbugStroke.MakeVxs(dbug_v1, dbug_v2); Render(dbug_v2, color); dbug_v1.Clear(); dbug_v2.Clear(); }
Affine BuildImageBoundsPath( int srcW, int srcH, VertexStore drawImageRectPath, double destX, double destY) { AffinePlan plan = new AffinePlan(); if (destX != 0 || destY != 0) { plan = AffinePlan.Translate(destX, destY); } drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return(Affine.NewMatix(plan)); }
Affine BuildImageBoundsPath(IImageReaderWriter sourceImage, VertexStore drawImageRectPath, double destX, double destY) { AffinePlan plan = new AffinePlan(); if (destX != 0 || destY != 0) { plan = AffinePlan.Translate(destX, destY); } int srcW = sourceImage.Width; int srcH = sourceImage.Height; drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return(Affine.NewMatix(plan)); }
public static void CreateBezierVxs3(VertexStore vxs, Vector2 start, Vector2 end, Vector2 control1) { var curve = new VectorMath.BezierCurveQuadric( start, end, control1); vxs.AddLineTo(start.x, start.y); float eachstep = (float)1 / NSteps; float stepSum = eachstep;//start for (int i = 1; i < NSteps; ++i) { var vector2 = curve.CalculatePoint(stepSum); vxs.AddLineTo(vector2.x, vector2.y); stepSum += eachstep; } vxs.AddLineTo(end.x, end.y); //------------------------------------------------------ //convert c3 to c4 //Vector2 c4p2, c4p3; //Curve3GetControlPoints(start, control1, end, out c4p2, out c4p3); //CreateBezierVxs4(vxs, start, end, c4p2, c4p3); }
public static void MakeLines(this Curve3Div curve, VertexStore vxs) { ArrayList <Vector2> m_points = curve.GetInternalPoints(); int j = m_points.Count; if (j > 0) { //others for (int i = 1; i < j; i++) { var p = m_points[i]; vxs.AddLineTo(p.x, p.y); } } }
public static void CreateBezierVxs3(VertexStore vxs, double x0, double y0, double x1, double y1, double x2, double y2) { //1. subdiv technique s_curve3Div.Init(x0, y0, x1, y1, x2, y2); ArrayList <Vector2> points = s_curve3Div.GetInternalPoints(); int n = 0; for (int i = points.Length - 1; i >= 0; --i) { Vector2 p = points[n++]; vxs.AddLineTo(p.x, p.y); } //2. old tech -- use incremental //var curve = new VectorMath.BezierCurveQuadric( // new Vector2(x0, y0), // new Vector2(x1, y1), // new Vector2(x2, y2)); //vxs.AddLineTo(x0, y0); //float eachstep = (float)1 / NSteps; //float stepSum = eachstep;//start //for (int i = NSteps - 1; i >= 0; --i) //{ // var vector2 = curve.CalculatePoint(stepSum); // vxs.AddLineTo(vector2.x, vector2.y); // stepSum += eachstep; //} //vxs.AddLineTo(x2, y2); }
static void CreateBezierVxs4(VertexStore vxs, double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) { //1. subdiv technique s_curve4Div.Init(x0, y0, x1, y1, x2, y2, x3, y3); ArrayList <Vector2> points = s_curve4Div.GetInternalPoints(); int n = 0; for (int i = points.Length - 1; i >= 0; --i) { Vector2 p = points[n++]; vxs.AddLineTo(p.x, p.y); } //---------------------------------------- //2. old tech -- use incremental //var curve = new VectorMath.BezierCurveCubic( // start, end, // control1, control2); //vxs.AddLineTo(start.x, start.y); //float eachstep = (float)1 / NSteps; //float stepSum = eachstep;//start //for (int i = NSteps - 1; i >= 0; --i) //{ // var vector2 = curve.CalculatePoint(stepSum); // vxs.AddLineTo(vector2.x, vector2.y); // stepSum += eachstep; //} //vxs.AddLineTo(end.x, end.y); }
Affine BuildImageBoundsPath( int srcW, int srcH, VertexStore drawImageRectPath, double destX, double destY) { AffinePlan plan = new AffinePlan(); if (destX != 0 || destY != 0) { plan = AffinePlan.Translate(destX, destY); } drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return Affine.NewMatix(plan); }
static Affine BuildImageBoundsPath(int srcW, int srcH, VertexStore drawImageRectPath, AffinePlan[] affPlans) { drawImageRectPath.Clear(); drawImageRectPath.AddMoveTo(0, 0); drawImageRectPath.AddLineTo(srcW, 0); drawImageRectPath.AddLineTo(srcW, srcH); drawImageRectPath.AddLineTo(0, srcH); drawImageRectPath.AddCloseFigure(); return Affine.NewMatix(affPlans); }
public static void ConvertToVxs(System.Drawing.Drawing2D.PathData pathdata, VertexStore outputVxs) { byte[] pointTypes = pathdata.Types; PointF[] points = pathdata.Points; int pointCount = points.Length; //from MSDN document //0 = start of figure (MoveTo) //1 = one of the two endpoints of a line (LineTo) //3 = an endpoint or control point of a cubic Bezier spline (4 points spline) //masks.. //0x7 = 111b (binary) => for masking lower 3 bits //0x20 = (1<<6) specific that point is a marker //0x80 = (1<<7) specific that point is the last point of a closed subpath( figure) //---------------------------------- //convert to Agg's VertexStorage int curvePointCount = 0; for (int i = 0; i < pointCount; ++i) { byte pointType = pointTypes[i]; PointF p = points[i]; switch (0x7 & pointType) { case 0: //move to outputVxs.AddMoveTo(p.X, p.Y); curvePointCount = 0; break; case 1: //line to outputVxs.AddLineTo(p.X, p.Y); curvePointCount = 0; break; case 3: //end point of control point of cubic Bezier spline { switch (curvePointCount) { case 0: { outputVxs.AddP2c(p.X, p.Y); curvePointCount++; } break; case 1: { outputVxs.AddP3c(p.X, p.Y); curvePointCount++; } break; case 2: { outputVxs.AddLineTo(p.X, p.Y); curvePointCount = 0; //reset } break; default: { throw new NotSupportedException(); } } } break; default: { } break; } if ((pointType >> 7) == 1) { //close figure to outputVxs.AddCloseFigure(); } if ((pointType >> 6) == 1) { } } }
void WriteOutput(VertexStore outputVxs, bool close) { //write output to if (close) { int positive_edgeCount = positiveSideVectors.Count; int negative_edgeCount = negativeSideVectors.Count; int n = positive_edgeCount - 1; Vector v = positiveSideVectors[n]; outputVxs.AddMoveTo(v.X, v.Y); for (; n >= 0; --n) { v = positiveSideVectors[n]; outputVxs.AddLineTo(v.X, v.Y); } outputVxs.AddCloseFigure(); //end ... create join to negative side //------------------------------------------ //create line join from positive to negative side v = negativeSideVectors[0]; outputVxs.AddMoveTo(v.X, v.Y); n = 1; for (; n < negative_edgeCount; ++n) { v = negativeSideVectors[n]; outputVxs.AddLineTo(v.X, v.Y); } //------------------------------------------ //close outputVxs.AddCloseFigure(); } else { int positive_edgeCount = positiveSideVectors.Count; int negative_edgeCount = negativeSideVectors.Count; //no a close shape stroke //create line cap for this // //positive Vector v = positiveSideVectors[0]; //----------- //1. moveto //2. CreateStartLineCap(outputVxs, v, negativeSideVectors[0], this.HalfStrokeWidth); //----------- int n = 1; for (; n < positive_edgeCount; ++n) { //increment n v = positiveSideVectors[n]; outputVxs.AddLineTo(v.X, v.Y); } //negative //---------------------------------- CreateEndLineCap(outputVxs, positiveSideVectors[positive_edgeCount - 1], negativeSideVectors[negative_edgeCount - 1], this.HalfStrokeWidth); //---------------------------------- for (n = negative_edgeCount - 2; n >= 0; --n) { //decrement n v = negativeSideVectors[n]; outputVxs.AddLineTo(v.X, v.Y); } outputVxs.AddCloseFigure(); } //reset positiveSideVectors.Clear(); negativeSideVectors.Clear(); }