本文整理汇总了C++中SkPath::addOval方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::addOval方法的具体用法?C++ SkPath::addOval怎么用?C++ SkPath::addOval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::addOval方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addInnerRoundedRectClip
void PlatformGraphicsContextSkia::addInnerRoundedRectClip(const IntRect& rect,
int thickness)
{
SkPath path;
SkRect r(rect);
path.addOval(r, SkPath::kCW_Direction);
// Only perform the inset if we won't invert r
if (2 * thickness < rect.width() && 2 * thickness < rect.height()) {
// Adding one to the thickness doesn't make the border too thick as
// it's painted over afterwards. But without this adjustment the
// border appears a little anemic after anti-aliasing.
r.inset(SkIntToScalar(thickness + 1), SkIntToScalar(thickness + 1));
path.addOval(r, SkPath::kCCW_Direction);
}
mCanvas->clipPath(path, SkRegion::kIntersect_Op, true);
}
示例2: draw
SkRect draw(SkCanvas* canvas, const SkPaint& paint) override {
SkPath path;
path.addCircle(15, 15, 10);
path.addOval(SkRect::MakeXYWH(2, 2, 22, 37));
path.setFillType(SkPath::kEvenOdd_FillType);
canvas->drawPath(path, paint);
return path.getBounds();
}
示例3: test_circlebounds
// ensure that we don't accidentally screw up the bounds when the oval is
// fractional, and the impl computes the center and radii, and uses them to
// reconstruct the edges of the circle.
// see bug# 1504910
static void test_circlebounds(SkCanvas* canvas) {
#ifdef SK_SCALAR_IS_FLOAT
SkRect r = { 1.39999998f, 1, 21.3999996f, 21 };
SkPath p;
p.addOval(r);
SkASSERT(r == p.getBounds());
#endif
}
示例4: drawRectSkeleton
void drawRectSkeleton(SkCanvas* max, const SkRect& r) {
SkPaint paint;
this->setupSkeletonPaint(&paint);
SkPath path;
fRectAsOval ? path.addOval(r) : path.addRect(r);
max->drawPath(path, paint);
}
示例5: addInnerRoundedRectClip
void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
{
if (paintingDisabled())
return;
SkRect r(rect);
if (!isRectSkiaSafe(getCTM(), r))
return;
SkPath path;
path.addOval(r, SkPath::kCW_Direction);
// only perform the inset if we won't invert r
if (2 * thickness < rect.width() && 2 * thickness < rect.height()) {
r.inset(SkIntToScalar(thickness) ,SkIntToScalar(thickness));
path.addOval(r, SkPath::kCCW_Direction);
}
platformContext()->canvas()->clipPath(path);
}
示例6: drawOval
void SkBitmapDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) {
CHECK_FOR_ANNOTATION(paint);
SkPath path;
path.addOval(oval);
// call the VIRTUAL version, so any subclasses who do handle drawPath aren't
// required to override drawOval.
this->drawPath(draw, path, paint, NULL, true);
}
示例7: addInnerRoundedRectClip
void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
{
if (paintingDisabled())
return;
SkRect r(rect);
SkPath path;
path.addOval(r, SkPath::kCW_Direction);
// only perform the inset if we won't invert r
if (2 * thickness < rect.width() && 2 * thickness < rect.height()) {
// Adding one to the thickness doesn't make the border too thick as
// it's painted over afterwards. But without this adjustment the
// border appears a little anemic after anti-aliasing.
r.inset(SkIntToScalar(thickness + 1), SkIntToScalar(thickness + 1));
path.addOval(r, SkPath::kCCW_Direction);
}
platformContext()->clipPathAntiAliased(path);
}
示例8: TextOnPathView
TextOnPathView() {
SkRect r;
r.set(SkIntToScalar(100), SkIntToScalar(100),
SkIntToScalar(300), SkIntToScalar(300));
fPath.addOval(r);
fPath.offset(SkIntToScalar(-50), SkIntToScalar(-50));
fHOffset = SkIntToScalar(50);
}
示例9: test_giantaa
// we used to assert if the bounds of the device (clip) was larger than 32K
// even when the path itself was smaller. We just draw and hope in the debug
// version to not assert.
static void test_giantaa() {
const int W = 400;
const int H = 400;
SkAutoTUnref<SkCanvas> canvas(SkCanvas::NewRasterN32(33000, 10));
SkPaint paint;
paint.setAntiAlias(true);
SkPath path;
path.addOval(SkRect::MakeXYWH(-10, -10, 20 + W, 20 + H));
canvas.get()->drawPath(path, paint);
}
示例10: test_giantaa
// we used to assert if the bounds of the device (clip) was larger than 32K
// even when the path itself was smaller. We just draw and hope in the debug
// version to not assert.
static void test_giantaa() {
const int W = 400;
const int H = 400;
auto surface(SkSurface::MakeRasterN32Premul(33000, 10));
SkPaint paint;
paint.setAntiAlias(true);
SkPath path;
path.addOval(SkRect::MakeXYWH(-10, -10, 20 + W, 20 + H));
surface->getCanvas()->drawPath(path, paint);
}
示例11: test_giantaa
// we used to assert if the bounds of the device (clip) was larger than 32K
// even when the path itself was smaller. We just draw and hope in the debug
// version to not assert.
static void test_giantaa(skiatest::Reporter* reporter) {
const int W = 400;
const int H = 400;
SkAutoTUnref<SkCanvas> canvas(new_canvas(33000, 10));
canvas.get()->clear(SK_ColorTRANSPARENT);
SkPaint paint;
paint.setAntiAlias(true);
SkPath path;
path.addOval(SkRect::MakeXYWH(-10, -10, 20 + W, 20 + H));
canvas.get()->drawPath(path, paint);
}
示例12: clipOutEllipseInRect
void GraphicsContext::clipOutEllipseInRect(const IntRect& rect)
{
if (paintingDisabled())
return;
SkRect oval(rect);
if (!isRectSkiaSafe(getCTM(), oval))
return;
SkPath path;
path.addOval(oval, SkPath::kCCW_Direction);
platformContext()->canvas()->clipPath(path, SkRegion::kDifference_Op);
}
示例13: onDraw
void onDraw(SkCanvas* canvas) override {
SkRect r = { 10, 10, 100, 60 };
SkPath path;
path.addRect(r); test_rev(canvas, path);
canvas->translate(0, 100);
path.offset(20, 20);
path.addRect(r); test_rev(canvas, path);
canvas->translate(0, 100);
path.reset();
path.moveTo(10, 10); path.lineTo(30, 30);
path.addOval(r);
r.offset(50, 20);
path.addOval(r);
test_rev(canvas, path);
path = hiragino_maru_goth_pro_e();
canvas->translate(0, 100);
test_rev(canvas, path);
}
示例14: onDraw
virtual void onDraw(SkCanvas* canvas)
{
switch (fStyle)
{
case kRect_Style:
canvas->drawRect(fRect, fPaint);
break;
case kOval_Style:
canvas->drawOval(fRect, fPaint);
break;
case kRRect_Style:
{
SkScalar rx = fRect.width() / 5;
SkScalar ry = fRect.height() / 5;
if (rx < ry)
{
ry = rx;
}
else
{
rx = ry;
}
canvas->drawRoundRect(fRect, rx, ry, fPaint);
break;
}
case kFrame_Style:
{
SkPath path;
path.addOval(fRect, SkPath::kCW_Direction);
SkRect r = fRect;
r.inset(fRect.width()/6, 0);
path.addOval(r, SkPath::kCCW_Direction);
canvas->drawPath(path, fPaint);
break;
}
}
}
示例15: addArc
void Path::addArc(const FloatPoint& p, float r, float sa, float ea,
bool clockwise) {
SkScalar cx = SkFloatToScalar(p.x());
SkScalar cy = SkFloatToScalar(p.y());
SkScalar radius = SkFloatToScalar(r);
SkRect oval;
oval.set(cx - radius, cy - radius, cx + radius, cy + radius);
float sweep = ea - sa;
bool prependOval = false;
/* Note if clockwise and the sign of the sweep disagree. This particular
logic was deduced from http://canvex.lazyilluminati.com/misc/arc.html
*/
if (clockwise && (sweep > 0 || sweep < -g2PI)) {
sweep = fmodf(sweep, g2PI) - g2PI;
} else if (!clockwise && (sweep < 0 || sweep > g2PI)) {
sweep = fmodf(sweep, g2PI) + g2PI;
}
// If the abs(sweep) >= 2PI, then we need to add a circle before we call
// arcTo, since it treats the sweep mod 2PI. We don't have a prepend call,
// so we just remember this, and at the end create a new path with an oval
// and our current path, and then swap then.
//
if (sweep >= g2PI || sweep <= -g2PI) {
prependOval = true;
// SkDebugf("addArc sa=%g ea=%g cw=%d sweep %g treat as circle\n", sa, ea, clockwise, sweep);
// now reduce sweep to just the amount we need, so that the current
// point is left where the caller expects it.
sweep = fmodf(sweep, g2PI);
}
sa = fast_mod(sa, g2PI);
SkScalar startDegrees = SkFloatToScalar(sa * g180OverPI);
SkScalar sweepDegrees = SkFloatToScalar(sweep * g180OverPI);
// SkDebugf("addArc sa=%g ea=%g cw=%d sweep=%g ssweep=%g\n", sa, ea, clockwise, sweep, SkScalarToFloat(sweepDegrees));
m_path->arcTo(oval, startDegrees, sweepDegrees, false);
if (prependOval) {
SkPath tmp;
tmp.addOval(oval);
tmp.addPath(*m_path);
m_path->swap(tmp);
}
}