inline void fill2EllipseLines(pb_rgba *pb, const uint32_t cx, const uint32_t cy, const unsigned int x, const unsigned int y, const uint32_t color) { int x1 = cx - x; int y1 = cy+y; int x2 = cx + x; int y2 = cy+y; if (clipLine(pb->frame, x1, y1, x2, y2)) { raster_rgba_hline_blend(pb, x1, y1, x2-x1, color); } y1 = cy - y; y2 = cy - y; if (clipLine(pb->frame, x1, y1, x2, y2)) { raster_rgba_hline_blend(pb, x1, y1, x2 - x1, color); } //raster_rgba_hline_blend(pb, cx - x, cy - y, 2 * x, color); }
void raster_rgba_convex_polygon_fill(pb_rgba *pb, coord *verts, const int nverts, const pb_rect &clipRect, int color) { // find topmost vertex of the polygon int vmin = findTopmostVertex(verts, nverts); // set starting line APolyDda ldda, rdda; int y = int(verts[vmin*2+1]); ldda.yend = rdda.yend = y; // setup polygon scanner for left side, starting from top ldda.setupPolyDda(verts, nverts, vmin, +1); // setup polygon scanner for right side, starting from top rdda.setupPolyDda(verts, nverts, vmin, -1); //setColor(poly.colorNative); while (true) { if (y >= ldda.yend) { if (y >= rdda.yend) { if (ldda.vertNext == rdda.vertNext) { // if same vertex, then done break; } int vnext = rdda.vertNext - 1; if (vnext < 0) { vnext = nverts - 1; } if (vnext == ldda.vertNext) { break; } } ldda.setupPolyDda(verts, nverts, ldda.vertNext, +1); // reset left side } // check for right dda hitting end of polygon side // if so, reset scanner if (y >= rdda.yend) { rdda.setupPolyDda(verts, nverts, rdda.vertNext, -1); } // fill span between two line-drawers, advance drawers when // hit vertices if (y >= clipRect.y) { raster_rgba_hline_blend(pb, round(ldda.x), y, round(rdda.x) - round(ldda.x), color); } ldda.x += ldda.dx; rdda.x += rdda.dx; // Advance y position. Exit if run off its bottom y += 1; if (y >= clipRect.y + clipRect.height) { break; } } }