bool KeyHole(Canvas &canvas, PixelScalar x, PixelScalar y, UPixelScalar radius, Angle start, Angle end, UPixelScalar inner_radius) { // dont draw if out of view PixelRect rc, bounds; SetRect(&rc, 0, 0, canvas.get_width(), canvas.get_height()); SetRect(&bounds, x - radius, y - radius, x + radius, y + radius); if (!IntersectRect(&bounds, &bounds, &rc)) return false; const int istart = NATIVE_TO_INT(start.Native()); const int iend = NATIVE_TO_INT(end.Native()); int npoly = 0; RasterPoint pt[66*2]; segment_poly(pt, x, y, radius, istart, iend, npoly); segment_poly(pt, x, y, inner_radius, iend, istart, npoly); assert(npoly <= 66*2); if (npoly) canvas.DrawPolygon(pt, npoly); return true; }
void RoundRect(Canvas &canvas, int left, int top, int right, int bottom, unsigned radius) { unsigned npoly = 0; RasterPoint pt[66*4]; segment_poly(pt, left + radius, top + radius, radius, INT_ANGLE_RANGE * 3 / 4, INT_ANGLE_RANGE - 1, npoly); segment_poly(pt, right - radius, top + radius, radius, 0, INT_ANGLE_RANGE / 4 - 1, npoly); segment_poly(pt, right - radius, bottom - radius, radius, INT_ANGLE_RANGE / 4, INT_ANGLE_RANGE / 2 - 1, npoly); segment_poly(pt, left + radius, bottom - radius, radius, INT_ANGLE_RANGE / 2, INT_ANGLE_RANGE * 3 / 4 - 1, npoly); assert(npoly < ARRAY_SIZE(pt)); if (npoly) canvas.DrawPolygon(pt, npoly); }
bool Annulus(Canvas &canvas, long x, long y, int radius, Angle start, Angle end, int inner_radius) { // dont draw if out of view PixelRect rc, bounds; SetRect(&rc, 0, 0, canvas.get_width(), canvas.get_height()); SetRect(&bounds, x - radius, y - radius, x + radius, y + radius); if (!IntersectRect(&bounds, &bounds, &rc)) return false; const int istart = NATIVE_TO_INT(start.value_native()); const int iend = NATIVE_TO_INT(end.value_native()); int npoly = 0; RasterPoint pt[66*2]; segment_poly(pt, x, y, radius, istart, iend, npoly); segment_poly(pt, x, y, inner_radius, iend, istart, npoly, false); assert(npoly <= 66*2); if (npoly) { canvas.polygon(pt, npoly); } return true; }
void RoundRect(Canvas &canvas, int left, int top, int right, int bottom, unsigned radius) { unsigned npoly = 0; BulkPixelPoint pt[66*4]; segment_poly(pt, PixelPoint(left + radius, top + radius), radius, INT_ANGLE_RANGE * 3 / 4, INT_ANGLE_RANGE - 1, npoly); segment_poly(pt, PixelPoint(right - radius, top + radius), radius, 0, INT_ANGLE_RANGE / 4 - 1, npoly); segment_poly(pt, PixelPoint(right - radius, bottom - radius), radius, INT_ANGLE_RANGE / 4, INT_ANGLE_RANGE / 2 - 1, npoly); segment_poly(pt, PixelPoint(left + radius, bottom - radius), radius, INT_ANGLE_RANGE / 2, INT_ANGLE_RANGE * 3 / 4 - 1, npoly); assert(npoly <= ARRAY_SIZE(pt)); if (npoly) canvas.DrawTriangleFan(pt, npoly); }
bool Segment(Canvas &canvas, PixelScalar x, PixelScalar y, UPixelScalar radius, Angle start, Angle end, bool horizon) { // dont draw if out of view PixelRect rc, bounds; SetRect(&rc, 0, 0, canvas.get_width(), canvas.get_height()); SetRect(&bounds, x - radius, y - radius, x + radius, y + radius); if (!IntersectRect(&bounds, &bounds, &rc)) return false; const int istart = NATIVE_TO_INT(start.Native()); const int iend = NATIVE_TO_INT(end.Native()); int npoly = 0; RasterPoint pt[66]; // add center point if (!horizon) { pt[0].x = x; pt[0].y = y; npoly = 1; } segment_poly(pt, x, y, radius, istart, iend, npoly); assert(npoly <= 66); if (npoly) canvas.DrawTriangleFan(pt, npoly); return true; }
void RoundRect(Canvas &canvas, PixelScalar left, PixelScalar top, PixelScalar right, PixelScalar bottom, UPixelScalar radius) { int npoly = 0; RasterPoint pt[66*4]; segment_poly(pt, left + radius, top + radius, radius, 3072, 4095, npoly); segment_poly(pt, right - radius, top + radius, radius, 0, 1023, npoly); segment_poly(pt, right - radius, bottom - radius, radius, 1024, 2047, npoly); segment_poly(pt, left + radius, bottom - radius, radius, 2048, 3071, npoly); assert(npoly <= 66*4); if (npoly) canvas.DrawPolygon(pt, npoly); }
bool Segment(Canvas &canvas, int x, int y, unsigned radius, Angle start, Angle end, bool horizon) { // dont draw if out of view if (!IsCircleVisible(canvas, x, y, radius)) return false; const int istart = NATIVE_TO_INT(start.Native()); const int iend = NATIVE_TO_INT(end.Native()); unsigned npoly = 0; RasterPoint pt[67]; // add center point if (!horizon) { pt[0].x = x; pt[0].y = y; npoly = 1; } segment_poly(pt, x, y, radius, istart, iend, npoly); assert(npoly <= ARRAY_SIZE(pt)); if (npoly) canvas.DrawTriangleFan(pt, npoly); return true; }
void RoundRect(Canvas &canvas, int left, int top, int right, int bottom, unsigned radius) { unsigned npoly = 0; RasterPoint pt[66*4]; segment_poly(pt, left + radius, top + radius, radius, 3072, 4095, npoly); segment_poly(pt, right - radius, top + radius, radius, 0, 1023, npoly); segment_poly(pt, right - radius, bottom - radius, radius, 1024, 2047, npoly); segment_poly(pt, left + radius, bottom - radius, radius, 2048, 3071, npoly); assert(npoly < ARRAY_SIZE(pt)); if (npoly) canvas.DrawPolygon(pt, npoly); }
bool KeyHole(Canvas &canvas, int x, int y, unsigned radius, Angle start, Angle end, unsigned inner_radius) { // dont draw if out of view if (!IsCircleVisible(canvas, x, y, radius)) return false; const int istart = NATIVE_TO_INT(start.Native()); const int iend = NATIVE_TO_INT(end.Native()); unsigned npoly = 0; RasterPoint pt[66*2]; segment_poly(pt, x, y, radius, istart, iend, npoly); segment_poly(pt, x, y, inner_radius, iend, istart, npoly); assert(npoly < ARRAY_SIZE(pt)); if (npoly) canvas.DrawPolygon(pt, npoly); return true; }
bool Annulus(Canvas &canvas, PixelPoint center, unsigned radius, Angle start, Angle end, unsigned inner_radius) { // dont draw if out of view if (!IsCircleVisible(canvas, center, radius)) return false; const int istart = NATIVE_TO_INT(start.Native()); const int iend = NATIVE_TO_INT(end.Native()); unsigned npoly = 0; BulkPixelPoint pt[66*2]; segment_poly(pt, center, radius, istart, iend, npoly); segment_poly(pt, center, inner_radius, iend, istart, npoly, false); assert(npoly <= ARRAY_SIZE(pt)); if (npoly) canvas.DrawPolygon(pt, npoly); return true; }