void CreateStartLineCap(VertexStore outputVxs, Vector v0, Vector v1, double edgeWidth) { switch (this.LineCapStyle) { default: throw new NotSupportedException(); case LineCap.Butt: outputVxs.AddMoveTo(v1.X, v1.Y); // moveto outputVxs.AddLineTo(v0.X, v0.Y); break; case LineCap.Square: { Vector delta = (v0 - v1).Rotate(90).NewLength(edgeWidth); //------------------------ outputVxs.AddMoveTo(v1.X + delta.X, v1.Y + delta.Y); outputVxs.AddLineTo(v0.X + delta.X, v0.Y + delta.Y); } break; case LineCap.Round: capVectors.Clear(); BuildBeginCap(v0.X, v0.Y, v1.X, v1.Y, capVectors); //---------------------------------------------------- int j = capVectors.Count; outputVxs.AddMoveTo(v1.X, v1.Y); for (int i = j - 1; i >= 0; --i) { Vector v = capVectors[i]; outputVxs.AddLineTo(v.X, v.Y); } break; } }
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); }
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(); }
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)); }
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)); }
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); }
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)); }
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(); }
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) { } } }
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); }
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); }