/// <summary> /// for fill shape /// </summary> /// <param name="sclineRas"></param> /// <param name="scline"></param> /// <param name="color"></param> /// <param name="shapeHint"></param> public void FillWithColor(GLScanlineRasterizer sclineRas, GLScanline scline, PixelFarm.Drawing.Color color) { //early exit if (color.A == 0) { return; } if (!sclineRas.RewindScanlines()) { return; } //----------------------------------------------- scline.ResetSpans(sclineRas.MinX, sclineRas.MaxX); //----------------------------------------------- var lineBuff = this.myLineBuffer; lineBuff.Clear(); while (sclineRas.SweepScanline(scline)) { int y = scline.Y; lineBuff.BeginNewLine(y); int num_spans = scline.SpanCount; byte[] covers = scline.GetCovers(); //copy data from scanline to lineBuff //TODO: move linebuf built into the scanline? for (int i = 1; i <= num_spans; ++i) { ScanlineSpan span = scline.GetSpan(i); if (span.len > 0) { //outline GLBlendSolidHSpan(span.x, span.len, true, lineBuff, color.A, covers, span.cover_index); } else { //fill int x = span.x; int x2 = (x - span.len - 1); GLBlendHLine(x, x2, true, lineBuff, color.A, covers[span.cover_index]); } } lineBuff.CloseLine(); } //---------------------------------- int nelements = myLineBuffer.Count; if (nelements > 0) { this.scanlineShader.AggDrawLines(myLineBuffer, nelements, color); } }
/// <summary> /// for fill shape /// </summary> /// <param name="sclineRas"></param> /// <param name="scline"></param> /// <param name="color"></param> /// <param name="shapeHint"></param> public void FillWithColor(GLScanlineRasterizer sclineRas, GLScanline scline, PixelFarm.Drawing.Color color) { //early exit if (color.A == 0) { return; } if (!sclineRas.RewindScanlines()) { return; } //----------------------------------------------- scline.ResetSpans(sclineRas.MinX, sclineRas.MaxX); //----------------------------------------------- this.mySinglePixelBuffer.Clear(); this.myLineBuffer.Clear(); while (sclineRas.SweepScanline(scline)) { int y = scline.Y; int num_spans = scline.SpanCount; byte[] covers = scline.GetCovers(); for (int i = 1; i <= num_spans; ++i) { ScanlineSpan span = scline.GetSpan(i); if (span.len > 0) { //outline GLBlendSolidHSpan(span.x, y, span.len, color, covers, span.cover_index); } else { //fill int x = span.x; int x2 = (x - span.len - 1); GLBlendHLine(x, y, x2, color, covers[span.cover_index]); } } } DrawPointAndLineWithVertices(); }