public GetNextVertex ( double &x, double &y ) : VertexCmd | ||
x | double | |
y | double | |
리턴 | VertexCmd |
//-----------------------------------------------------bounding_rect_single //template<class VertexSource, class CoordT> static bool GetBoundingRect( VertexStoreSnap vs, out int x1, out int y1, out int x2, out int y2) { double x_d = 0; double y_d = 0; int x = 0; int y = 0; bool first = true; x1 = 1; y1 = 1; x2 = 0; y2 = 0; VertexSnapIter vsnapIter = vs.GetVertexSnapIter(); VertexCmd PathAndFlags; while (!VertexHelper.IsEmpty(PathAndFlags = vsnapIter.GetNextVertex(out x_d, out y_d))) { x = (int)x_d; y = (int)y_d; if (VertexHelper.IsVertextCommand(PathAndFlags)) { if (first) { x1 = x; y1 = y; x2 = x; y2 = y; first = false; } else { if (x < x1) { x1 = x; } if (y < y1) { y1 = y; } if (x > x2) { x2 = x; } if (y > y2) { y2 = y; } } } } return(x1 <= x2 && y1 <= y2); }
public void AddPath(VertexStoreSnap snap) { double x = 0; double y = 0; if (m_cellAARas.Sorted) { Reset(); } if (snap.VxsHasMoreThanOnePart) { //**** //render all parts VertexStore vxs = snap.GetInternalVxs(); int j = vxs.Count; for (int i = 0; i < j; ++i) { var cmd = vxs.GetVertex(i, out x, out y); if (cmd != VertexCmd.Stop) { AddVertex(cmd, x, y); } } } else { VertexSnapIter snapIter = snap.GetVertexSnapIter(); VertexCmd cmd; int dbugVertexCount = 0; while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop) { dbugVertexCount++; AddVertex(cmd, x, y); } } }
/// <summary> /// we do NOT store snap *** /// </summary> /// <param name="snap"></param> public void AddPath(VertexStoreSnap snap) { //----------------------------------------------------- //*** we extract vertext command and coord(x,y) from //the snap but not store the snap inside rasterizer //----------------------------------------------------- double x = 0; double y = 0; if (m_cellAARas.Sorted) { Reset(); } float offsetOrgX = OffsetOriginX; float offsetOrgY = OffsetOriginY; VertexSnapIter snapIter = snap.GetVertexSnapIter(); VertexCmd cmd; #if DEBUG int dbugVertexCount = 0; #endif if (ExtendX3ForSubPixelRendering) { while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore) { #if DEBUG dbugVertexCount++; #endif //--------------------------------------------- //NOTE: we scale horizontal 3 times. //subpixel renderer will shrink it to 1 //--------------------------------------------- AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY); } } else { while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore) { #if DEBUG dbugVertexCount++; #endif AddVertex(cmd, x + offsetOrgX, y + offsetOrgY); } } // if (snap.VxsHasMoreThanOnePart) // { // //**** // //render all parts // VertexStore vxs = snap.GetInternalVxs(); // int j = vxs.Count; // if (UseSubPixelRendering) // { // for (int i = 0; i < j; ++i) // { // var cmd = vxs.GetVertex(i, out x, out y); // if (cmd != VertexCmd.Stop) // { // //AddVertext 1 of 4 // AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY); // } // } // } // else // { // for (int i = 0; i < j; ++i) // { // var cmd = vxs.GetVertex(i, out x, out y); // if (cmd != VertexCmd.Stop) // { // //AddVertext 2 of 4 // AddVertex(cmd, x + offsetOrgX, y + offsetOrgY); // } // } // } // } // else // { // VertexSnapIter snapIter = snap.GetVertexSnapIter(); // VertexCmd cmd; //#if DEBUG // int dbugVertexCount = 0; //#endif // if (UseSubPixelRendering) // { // while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop) // { //#if DEBUG // dbugVertexCount++; //#endif // //AddVertext 3 of 4 // AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY); // } // } // else // { // while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop) // { //#if DEBUG // dbugVertexCount++; //#endif // //AddVertext 4 of 4 // AddVertex(cmd, x + offsetOrgX, y + offsetOrgY); // } // } // } }
/// <summary> /// fill with BitmapBufferExtension lib /// </summary> void FillWithBxt(VertexStoreSnap snap) { //transate the vxs/snap to command double x = 0; double y = 0; double offsetOrgX = this.OriginX; double offsetOrgY = this.OriginY; VertexSnapIter snapIter = snap.GetVertexSnapIter(); VertexCmd cmd; int latestMoveToX = 0, latestMoveToY = 0; int latestX = 0, latestY = 0; bool closed = false; _reusablePolygonList.Clear(); while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore) { x += offsetOrgX; y += offsetOrgY; switch (cmd) { case VertexCmd.MoveTo: { if (_reusablePolygonList.Count > 0) { //no drawline _reusablePolygonList.Clear(); } closed = false; _reusablePolygonList.Add(latestMoveToX = latestX = (int)Math.Round(x)); _reusablePolygonList.Add(latestMoveToY = latestY = (int)Math.Round(y)); } break; case VertexCmd.LineTo: case VertexCmd.P2c: case VertexCmd.P3c: { //collect to the polygon _reusablePolygonList.Add(latestX = (int)Math.Round(x)); _reusablePolygonList.Add(latestY = (int)Math.Round(y)); } break; case VertexCmd.Close: case VertexCmd.CloseAndEndFigure: { if (_reusablePolygonList.Count > 0) { //flush by draw line _reusablePolygonList.Add(latestX = latestMoveToX); _reusablePolygonList.Add(latestY = latestMoveToY); _bxt.FillPolygon(_reusablePolygonList.ToArray(), this.fillColor.ToARGB()); } _reusablePolygonList.Clear(); closed = true; } break; default: break; } } //--------------- if (!closed && (_reusablePolygonList.Count > 0) && (latestX == latestMoveToX) && (latestY == latestMoveToY)) { //flush by draw line _reusablePolygonList.Add(latestMoveToX); _reusablePolygonList.Add(latestMoveToY); _bxt.FillPolygon(_reusablePolygonList.ToArray(), this.fillColor.ToARGB()); } }