本文整理汇总了C++中SkRRect::setRectRadii方法的典型用法代码示例。如果您正苦于以下问题:C++ SkRRect::setRectRadii方法的具体用法?C++ SkRRect::setRectRadii怎么用?C++ SkRRect::setRectRadii使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkRRect
的用法示例。
在下文中一共展示了SkRRect::setRectRadii方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: switch
static void draw_45(SkCanvas* canvas, SkRRect::Corner corner,
SkScalar dist, const SkPoint& center) {
SkRRect::Corner left = SkRRect::kUpperLeft_Corner, right = SkRRect::kUpperLeft_Corner;
SkVector dir = { 0, 0 };
constexpr SkScalar kSize = 64.0f / SK_ScalarSqrt2;
switch (corner) {
case SkRRect::kUpperLeft_Corner:
left = SkRRect::kUpperRight_Corner;
right = SkRRect::kLowerLeft_Corner;
dir.set(-SK_ScalarRoot2Over2, -SK_ScalarRoot2Over2);
break;
case SkRRect::kUpperRight_Corner:
left = SkRRect::kUpperLeft_Corner;
right = SkRRect::kLowerRight_Corner;
dir.set(SK_ScalarRoot2Over2, -SK_ScalarRoot2Over2);
break;
case SkRRect::kLowerRight_Corner:
left = SkRRect::kLowerLeft_Corner;
right = SkRRect::kUpperRight_Corner;
dir.set(SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
break;
case SkRRect::kLowerLeft_Corner:
left = SkRRect::kLowerRight_Corner;
right = SkRRect::kUpperLeft_Corner;
dir.set(-SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
break;
default:
SkFAIL("Invalid shape.");
}
SkRect r = SkRect::MakeWH(kSize, kSize);
// UL, UR, LR, LL
SkVector radii[4] = { { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f } };
radii[left] = SkVector::Make(kSize, kSize);
radii[right] = SkVector::Make(kSize, kSize);
SkRRect rr;
rr.setRectRadii(
offset_center_to(r.roundOut(), center.fX + dist*dir.fX, center.fY + dist*dir.fY),
radii);
SkRRect occRR;
dist -= 10.0f;
occRR.setRectRadii(
offset_center_to(r.roundOut(), center.fX + dist*dir.fX, center.fY + dist*dir.fY),
radii);
draw_rrect(canvas, rr, occRR);
}
示例3: while
std::unique_ptr<GrFragmentProcessor> EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkVector r[4];
r[SkRRect::kUpperLeft_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f);
// ensure at least one corner really is elliptical
do {
r[SkRRect::kUpperLeft_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9.f);
} while (r[SkRRect::kUpperLeft_Corner].fY == r[SkRRect::kUpperLeft_Corner].fX);
SkRRect rrect;
if (d->fRandom->nextBool()) {
// half the time create a four-radii rrect.
r[SkRRect::kLowerRight_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f);
r[SkRRect::kLowerRight_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9.f);
r[SkRRect::kUpperRight_Corner].fX = r[SkRRect::kLowerRight_Corner].fX;
r[SkRRect::kUpperRight_Corner].fY = r[SkRRect::kUpperLeft_Corner].fY;
r[SkRRect::kLowerLeft_Corner].fX = r[SkRRect::kUpperLeft_Corner].fX;
r[SkRRect::kLowerLeft_Corner].fY = r[SkRRect::kLowerRight_Corner].fY;
rrect.setRectRadii(SkRect::MakeWH(w, h), r);
} else {
rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
r[SkRRect::kUpperLeft_Corner].fY);
}
std::unique_ptr<GrFragmentProcessor> fp;
do {
GrClipEdgeType et = (GrClipEdgeType)d->fRandom->nextULessThan(kGrClipEdgeTypeCnt);
fp = GrRRectEffect::Make(et, rrect, *d->caps()->shaderCaps());
} while (nullptr == fp);
return fp;
}
示例4:
static void test_tricky_radii_crbug_458522(skiatest::Reporter* reporter) {
SkRRect rr;
const SkRect bounds = { 3709, 3709, 3709 + 7402, 3709 + 29825 };
const SkScalar rad = 12814;
const SkVector vec[] = { { rad, rad }, { 0, rad }, { rad, rad }, { 0, rad } };
rr.setRectRadii(bounds, vec);
}
示例5: test_mix
static void test_mix(skiatest::Reporter* reporter) {
// Test out mixed degenerate and non-degenerate geometry with Conics
const SkVector radii[4] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 100, 100 } };
SkRect r = SkRect::MakeWH(100, 100);
SkRRect rr;
rr.setRectRadii(r, radii);
path_contains_rrect_check(reporter, rr);
}
示例6: surface
// http://crbug.com/472147
// This is a simplified version from the bug. RRect radii not properly scaled.
static void test_crbug_472147_simple(skiatest::Reporter* reporter) {
auto surface(SkSurface::MakeRasterN32Premul(1000, 1000));
SkCanvas* canvas = surface->getCanvas();
SkPaint p;
SkRect r = SkRect::MakeLTRB(-246.0f, 33.0f, 848.0f, 33554464.0f);
SkVector radii[4] = {
{ 13.0f, 8.0f }, { 170.0f, 2.0 }, { 256.0f, 33554430.0f }, { 120.0f, 5.0f }
};
SkRRect rr;
rr.setRectRadii(r, radii);
canvas->drawRRect(rr, p);
}
示例7: test_tricky_radii
static void test_tricky_radii(skiatest::Reporter* reporter) {
{
// crbug.com/458522
SkRRect rr;
const SkRect bounds = { 3709, 3709, 3709 + 7402, 3709 + 29825 };
const SkScalar rad = 12814;
const SkVector vec[] = { { rad, rad }, { 0, rad }, { rad, rad }, { 0, rad } };
rr.setRectRadii(bounds, vec);
path_contains_rrect_check(reporter, rr);
}
{
// crbug.com//463920
SkRect r = SkRect::MakeLTRB(0, 0, 1009, 33554432.0);
SkVector radii[4] = {
{ 13.0f, 8.0f }, { 170.0f, 2.0 }, { 256.0f, 33554432.0 }, { 110.0f, 5.0f }
};
SkRRect rr;
rr.setRectRadii(r, radii);
path_contains_rrect_nocheck(reporter, rr);
}
}
示例8: test_tricky_radii
static void test_tricky_radii(skiatest::Reporter* reporter) {
{
// crbug.com/458522
SkRRect rr;
const SkRect bounds = { 3709, 3709, 3709 + 7402, 3709 + 29825 };
const SkScalar rad = 12814;
const SkVector vec[] = { { rad, rad }, { 0, rad }, { rad, rad }, { 0, rad } };
rr.setRectRadii(bounds, vec);
}
{
// crbug.com//463920
SkRect r = SkRect::MakeLTRB(0, 0, 1009, 33554432.0);
SkVector radii[4] = {
{ 13.0f, 8.0f }, { 170.0f, 2.0 }, { 256.0f, 33554432.0 }, { 110.0f, 5.0f }
};
SkRRect rr;
rr.setRectRadii(r, radii);
REPORTER_ASSERT(reporter, (double) rr.radii(SkRRect::kUpperRight_Corner).fY +
(double) rr.radii(SkRRect::kLowerRight_Corner).fY <=
rr.height());
}
}
示例9: 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;
}
示例10: draw
void draw(SkCanvas* canvas) {
SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
rrect.dumpHex();
SkRect bounds = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
SkBits2Float(0x3f2aaaab), /* 0.666667 */
SkBits2Float(0x3f5b6db7), /* 0.857143 */
SkBits2Float(0x3f2aaaab) /* 0.666667 */);
const SkPoint corners[] = {
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
};
SkRRect copy;
copy.setRectRadii(bounds, corners);
SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
}
示例11: test_round_rect_transform
static void test_round_rect_transform(skiatest::Reporter* reporter) {
SkRRect rrect;
{
SkRect r = { 0, 0, kWidth, kHeight };
rrect.setRectXY(r, SkIntToScalar(4), SkIntToScalar(7));
test_transform_helper(reporter, rrect);
}
{
SkRect r = { SkIntToScalar(5), SkIntToScalar(15),
SkIntToScalar(27), SkIntToScalar(34) };
SkVector radii[4] = { { 0, SkIntToScalar(1) },
{ SkIntToScalar(2), SkIntToScalar(3) },
{ SkIntToScalar(4), SkIntToScalar(5) },
{ SkIntToScalar(6), SkIntToScalar(7) } };
rrect.setRectRadii(r, radii);
test_transform_helper(reporter, rrect);
}
}
示例12: DrawRect
void DrawRect(SkiaRenderer _r, Paint _paint, Rect _rect, Point * raddis) {
Renderer * r = Renderer::fromPtr(_r);
SkVector skRads[4];
for (int i=0; i<4; ++i) {
skRads[i] = SkPoint::Make(raddis[i].x, raddis[i].y);
}
SkRect rect = toSkRect(_rect);
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(_paint.fillColor);
paint.setStyle(SkPaint::kFill_Style);
SkRRect rr;
rr.setRectRadii(rect, skRads);
r->canvas->drawRRect(rr, paint);
paint.setColor(_paint.strokeColor);
paint.setStrokeWidth(_paint.strokeWidth);
paint.setStyle(SkPaint::kStroke_Style);
r->canvas->drawRRect(rr, paint);
}
示例13: appendToWebDisplayItemList
void ClipDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, WebDisplayItemList* list) const
{
WebVector<SkRRect> webRoundedRects(m_roundedRectClips.size());
for (size_t i = 0; i < m_roundedRectClips.size(); ++i) {
FloatRoundedRect::Radii rectRadii = m_roundedRectClips[i].radii();
SkVector skRadii[4];
skRadii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(rectRadii.topLeft().width()),
SkIntToScalar(rectRadii.topLeft().height()));
skRadii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(rectRadii.topRight().width()),
SkIntToScalar(rectRadii.topRight().height()));
skRadii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(rectRadii.bottomRight().width()),
SkIntToScalar(rectRadii.bottomRight().height()));
skRadii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(rectRadii.bottomLeft().width()),
SkIntToScalar(rectRadii.bottomLeft().height()));
SkRRect skRoundedRect;
skRoundedRect.setRectRadii(m_roundedRectClips[i].rect(), skRadii);
webRoundedRects[i] = skRoundedRect;
}
list->appendClipItem(visualRect, m_clipRect, webRoundedRects);
}
示例14: TestCreate
GrFragmentProcessor* EllipticalRRectEffect::TestCreate(SkRandom* random,
GrContext*,
const GrDrawTargetCaps& caps,
GrTexture*[]) {
SkScalar w = random->nextRangeScalar(20.f, 1000.f);
SkScalar h = random->nextRangeScalar(20.f, 1000.f);
SkVector r[4];
r[SkRRect::kUpperLeft_Corner].fX = random->nextRangeF(kRadiusMin, 9.f);
// ensure at least one corner really is elliptical
do {
r[SkRRect::kUpperLeft_Corner].fY = random->nextRangeF(kRadiusMin, 9.f);
} while (r[SkRRect::kUpperLeft_Corner].fY == r[SkRRect::kUpperLeft_Corner].fX);
SkRRect rrect;
if (random->nextBool()) {
// half the time create a four-radii rrect.
r[SkRRect::kLowerRight_Corner].fX = random->nextRangeF(kRadiusMin, 9.f);
r[SkRRect::kLowerRight_Corner].fY = random->nextRangeF(kRadiusMin, 9.f);
r[SkRRect::kUpperRight_Corner].fX = r[SkRRect::kLowerRight_Corner].fX;
r[SkRRect::kUpperRight_Corner].fY = r[SkRRect::kUpperLeft_Corner].fY;
r[SkRRect::kLowerLeft_Corner].fX = r[SkRRect::kUpperLeft_Corner].fX;
r[SkRRect::kLowerLeft_Corner].fY = r[SkRRect::kLowerRight_Corner].fY;
rrect.setRectRadii(SkRect::MakeWH(w, h), r);
} else {
rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
r[SkRRect::kUpperLeft_Corner].fY);
}
GrFragmentProcessor* fp;
do {
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt);
fp = GrRRectEffect::Create(et, rrect);
} while (NULL == fp);
return fp;
}
示例15: onDrawContent
void onDrawContent(SkCanvas* canvas) override {
SkPaint paintFill;
SkPaint paintStroke;
SkPath path;
canvas->save();
canvas->translate(150, 150);
canvas->scale(0.4f, 0.4f);
canvas->rotate(-180.f/2.f);
paintFill.setAntiAlias(true);
paintFill.setColor(SK_ColorBLACK);
paintStroke.setAntiAlias(true);
paintStroke.setStyle(SkPaint::kStroke_Style);
paintStroke.setColor(SK_ColorBLACK);
paintStroke.setStrokeWidth(8);
paintStroke.setStrokeCap(SkPaint::kRound_Cap);
// Hour marks
SkRect rect;
#ifndef USE_PATH
rect = SkRect::MakeLTRB(200-4, -4, 240+4, 4);
SkRRect rrect;
SkVector radii[4] = {{4,4}, {4,4}, {4,4}, {4,4}};
rrect.setRectRadii(rect, radii);
#endif
canvas->save();
for (int i=0;i<12;i++){
canvas->rotate(180.f/6.f);
#ifdef USE_PATH
path.reset();
path.moveTo(200,0);
path.lineTo(240,0);
canvas->drawPath(path, paintStroke);
#else
canvas->drawRRect(rrect, paintFill);
#endif
}
canvas->restore();
// Minute marks
canvas->save();
#ifdef USE_PATH
paintStroke.setStrokeWidth(5);
#else
rect = SkRect::MakeLTRB(231.5f, -2.5f, 242.5, 2.5f);
radii[0] = SkPoint::Make(2.5f,2.5f);
radii[1] = SkPoint::Make(2.5f,2.5f);
radii[2] = SkPoint::Make(2.5f,2.5f);
radii[3] = SkPoint::Make(2.5f,2.5f);
rrect.setRectRadii(rect, radii);
#endif
for (int i=0;i<60;i++){
if (i%5 == 0) {
canvas->rotate(180.f/30.f);
continue;
}
#ifdef USE_PATH
path.reset();
path.moveTo(234,0);
path.lineTo(240,0);
canvas->drawPath(path, paintStroke);
#else
canvas->drawRRect(rrect, paintFill);
#endif
canvas->rotate(180.f/30.f);
}
canvas->restore();
SkTime::DateTime time;
SkTime::GetDateTime(&time);
time.fHour = time.fHour >= 12 ? time.fHour-12 : time.fHour;
paintFill.setColor(SK_ColorBLACK);
// Write hours
canvas->save();
canvas->rotate(time.fHour*(180.f/6.f) + time.fMinute*(180.f/360.f)
+ time.fSecond*(180.f/21600.f) );
#ifdef USE_PATH
paintStroke.setStrokeWidth(14);
path.reset();
path.moveTo(-20,0);
path.lineTo(80,0);
canvas->drawPath(path, paintStroke);
#else
rect = SkRect::MakeLTRB(-20-7, -7, 80+7, 7);
radii[0] = SkPoint::Make(7,7);
radii[1] = SkPoint::Make(7,7);
radii[2] = SkPoint::Make(7,7);
radii[3] = SkPoint::Make(7,7);
rrect.setRectRadii(rect, radii);
canvas->drawRRect(rrect, paintFill);
#endif
canvas->restore();
// Write minutes
canvas->save();
canvas->rotate(time.fMinute*(180.f/30.f)
+ time.fSecond*(180.f/1800.f) );
#ifdef USE_PATH
//.........这里部分代码省略.........