本文整理汇总了C++中SkRRect::setOval方法的典型用法代码示例。如果您正苦于以下问题:C++ SkRRect::setOval方法的具体用法?C++ SkRRect::setOval怎么用?C++ SkRRect::setOval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkRRect
的用法示例。
在下文中一共展示了SkRRect::setOval方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_empty
// Test that all the SkRRect entry points correctly handle un-sorted and
// zero-sized input rects
static void test_empty(skiatest::Reporter* reporter) {
static const SkRect oooRects[] = { // out of order
{ 100, 0, 0, 100 }, // ooo horizontal
{ 0, 100, 100, 0 }, // ooo vertical
{ 100, 100, 0, 0 }, // ooo both
};
static const SkRect emptyRects[] = {
{ 100, 100, 100, 200 }, // empty horizontal
{ 100, 100, 200, 100 }, // empty vertical
{ 100, 100, 100, 100 }, // empty both
{ 0, 0, 0, 0 } // setEmpty-empty
};
static const SkVector radii[4] = { { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 } };
SkRRect r;
for (size_t i = 0; i < SK_ARRAY_COUNT(oooRects); ++i) {
r.setRect(oooRects[i]);
REPORTER_ASSERT(reporter, !r.isEmpty());
r.setOval(oooRects[i]);
REPORTER_ASSERT(reporter, !r.isEmpty());
r.setRectXY(oooRects[i], 1, 2);
REPORTER_ASSERT(reporter, !r.isEmpty());
r.setNinePatch(oooRects[i], 0, 1, 2, 3);
REPORTER_ASSERT(reporter, !r.isEmpty());
r.setRectRadii(oooRects[i], radii);
REPORTER_ASSERT(reporter, !r.isEmpty());
}
for (size_t i = 0; i < SK_ARRAY_COUNT(emptyRects); ++i) {
r.setRect(emptyRects[i]);
REPORTER_ASSERT(reporter, r.isEmpty());
r.setOval(emptyRects[i]);
REPORTER_ASSERT(reporter, r.isEmpty());
r.setRectXY(emptyRects[i], 1, 2);
REPORTER_ASSERT(reporter, r.isEmpty());
r.setNinePatch(emptyRects[i], 0, 1, 2, 3);
REPORTER_ASSERT(reporter, r.isEmpty());
r.setRectRadii(emptyRects[i], radii);
REPORTER_ASSERT(reporter, r.isEmpty());
}
}
示例2: draw
void draw(SkCanvas* canvas) {
canvas->clear(SK_ColorWHITE);
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(0x8055aaff);
SkRRect oval;
oval.setOval({10, 20, 90, 100});
canvas->clipRRect(oval, SkClipOp::kIntersect, true);
canvas->drawCircle(70, 100, 60, paint);
}
示例3: canvas
DEF_TEST(CanvasState_test_soft_clips, reporter) {
SkBitmap bitmap;
bitmap.allocN32Pixels(10, 10);
SkCanvas canvas(bitmap);
SkRRect roundRect;
roundRect.setOval(SkRect::MakeWH(5, 5));
canvas.clipRRect(roundRect, SkCanvas::kIntersect_Op, true);
SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
REPORTER_ASSERT(reporter, !state);
}
示例4: makeRRect
SkRRect makeRRect() {
SkRRect rrect;
RandomSetRRect rrectType = makeSetRRectType();
if (fPrintName) {
SkDebugf("%.*s%s\n", fPathDepth * 3, fTab, gRandomSetRRectNames[rrectType]);
}
switch (rrectType) {
case kSetEmpty:
rrect.setEmpty();
break;
case kSetRect: {
SkRect rect = makeRect();
rrect.setRect(rect);
}
break;
case kSetOval: {
SkRect oval = makeRect();
rrect.setOval(oval);
}
break;
case kSetRectXY: {
SkRect rect = makeRect();
SkScalar xRad = makeScalar();
SkScalar yRad = makeScalar();
rrect.setRectXY(rect, xRad, yRad);
}
break;
case kSetNinePatch: {
SkRect rect = makeRect();
SkScalar leftRad = makeScalar();
SkScalar topRad = makeScalar();
SkScalar rightRad = makeScalar();
SkScalar bottomRad = makeScalar();
rrect.setNinePatch(rect, leftRad, topRad, rightRad, bottomRad);
SkDebugf(""); // keep locals in scope
}
break;
case kSetRectRadii: {
SkRect rect = makeRect();
SkVector radii[4];
makeVectorArray(SK_ARRAY_COUNT(radii), radii);
rrect.setRectRadii(rect, radii);
}
break;
}
return rrect;
}
示例5: canvas
DEF_TEST(CanvasState_test_soft_clips, reporter) {
SkBitmap bitmap;
bitmap.allocN32Pixels(10, 10);
SkCanvas canvas(bitmap);
SkRRect roundRect;
roundRect.setOval(SkRect::MakeWH(5, 5));
canvas.clipRRect(roundRect, SkRegion::kIntersect_Op, true);
SkSetErrorCallback(error_callback, NULL);
SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
REPORTER_ASSERT(reporter, !state);
REPORTER_ASSERT(reporter, kInvalidOperation_SkError == SkGetLastError());
SkClearLastError();
}
示例6:
void SkClipStack::Element::initPath(int saveCount, const SkPath& path, SkRegion::Op op,
bool doAA) {
if (!path.isInverseFillType()) {
SkRect r;
if (path.isRect(&r)) {
this->initRect(saveCount, r, op, doAA);
return;
}
SkRect ovalRect;
if (path.isOval(&ovalRect)) {
SkRRect rrect;
rrect.setOval(ovalRect);
this->initRRect(saveCount, rrect, op, doAA);
return;
}
}
fPath.set(path);
fPath.get()->setIsVolatile(true);
fType = kPath_Type;
this->initCommon(saveCount, op, doAA);
}
示例7: onDraw
void onDraw(SkCanvas* canvas) override {
// Set up a gradient paint for a rect.
// And non-gradient paint for other objects.
canvas->drawColor(SK_ColorWHITE);
SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
paint.setAntiAlias(true);
paint.setStrokeWidth(4);
paint.setColor(0xFFFE938C);
SkRect rect = SkRect::MakeXYWH(10, 10, 100, 160);
SkPoint points[2] = {
SkPoint::Make(0.0f, 0.0f),
SkPoint::Make(256.0f, 256.0f)
};
SkColor colors[2] = {SK_ColorBLUE, SK_ColorYELLOW};
SkPaint newPaint(paint);
newPaint.setShader(SkGradientShader::MakeLinear(
points, colors, nullptr, 2, SkTileMode::kClamp));
canvas->drawRect(rect, newPaint);
SkRRect oval;
oval.setOval(rect);
oval.offset(40, 80);
paint.setColor(0xFFE6B89C);
canvas->drawRRect(oval, paint);
paint.setColor(0xFF9CAFB7);
canvas->drawCircle(180, 50, 25, paint);
rect.offset(80, 50);
paint.setColor(0xFF4281A4);
paint.setStyle(SkPaint::kStroke_Style);
canvas->drawRoundRect(rect, 10, 10, paint);
}
示例8: SkScalarHalf
// Test out the case where an oval already off in space is translated/scaled
// further off into space - yielding numerical issues when the rect & radii
// are transformed separatly
// BUG=skia:2696
static void test_issue_2696(skiatest::Reporter* reporter) {
SkRRect rrect;
SkRect r = { 28443.8594f, 53.1428604f, 28446.7148f, 56.0000038f };
rrect.setOval(r);
SkMatrix xform;
xform.setAll(2.44f, 0.0f, 485411.7f,
0.0f, 2.44f, -438.7f,
0.0f, 0.0f, 1.0f);
SkRRect dst;
bool success = rrect.transform(xform, &dst);
REPORTER_ASSERT(reporter, success);
SkScalar halfWidth = SkScalarHalf(dst.width());
SkScalar halfHeight = SkScalarHalf(dst.height());
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter,
SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fX, halfWidth));
REPORTER_ASSERT(reporter,
SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fY, halfHeight));
}
}
示例9: create_circle
SkRRect create_circle(const SkPoint& offset) {
SkRRect circle;
circle.setOval(create_rect(offset));
return circle;
}