本文整理汇总了C++中SkRect::toQuad方法的典型用法代码示例。如果您正苦于以下问题:C++ SkRect::toQuad方法的具体用法?C++ SkRect::toQuad怎么用?C++ SkRect::toQuad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkRect
的用法示例。
在下文中一共展示了SkRect::toQuad方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_rect
static void draw_rect(SkCanvas* canvas, bool showGL, int flags) {
SkPaint paint;
paint.setAntiAlias(true);
SkRect r = SkRect::MakeLTRB(50, 70, 250, 370);
setFade(&paint, showGL);
canvas->drawRect(r, paint);
if (showGL) {
show_mesh(canvas, r);
}
canvas->translate(320, 0);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(25);
canvas->drawRect(r, paint);
if (showGL) {
SkScalar rad = paint.getStrokeWidth() / 2;
SkPoint pts[8];
r.outset(rad, rad);
r.toQuad(&pts[0]);
r.inset(rad*2, rad*2);
r.toQuad(&pts[4]);
const uint16_t indices[] = {
0, 4, 1, 5, 2, 6, 3, 7, 0, 4
};
show_mesh(canvas, pts, indices, SK_ARRAY_COUNT(indices));
}
}
示例2: onDrawSelection
virtual void onDrawSelection(SkCanvas* canvas) {
SkRect r;
this->getBounds(&r);
SkPaint paint;
SkPoint pts[4];
r.toQuad(pts);
paint.setStrokeWidth(SkIntToScalar(10));
paint.setColor(0x80FF8844);
paint.setStrokeCap(SkPaint::kRound_Cap);
canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, pts, paint);
}
示例3: drawShape
void drawShape(SkCanvas* canvas,
SkPaint* paint,
ShapeType type) {
static const SkRect kRect = SkRect::MakeXYWH(SkIntToScalar(-50), SkIntToScalar(-50),
SkIntToScalar(75), SkIntToScalar(105));
switch (type) {
case kCircle_ShapeType:
canvas->drawCircle(0, 0, 50, *paint);
break;
case kRoundRect_ShapeType:
canvas->drawRoundRect(kRect, SkIntToScalar(10), SkIntToScalar(20), *paint);
break;
case kRect_ShapeType:
canvas->drawRect(kRect, *paint);
break;
case kConvexPath_ShapeType:
if (fConvexPath.isEmpty()) {
SkPoint points[4];
kRect.toQuad(points);
fConvexPath.moveTo(points[0]);
fConvexPath.quadTo(points[1], points[2]);
fConvexPath.quadTo(points[3], points[0]);
SkASSERT(fConvexPath.isConvex());
}
canvas->drawPath(fConvexPath, *paint);
break;
case kConcavePath_ShapeType:
if (fConcavePath.isEmpty()) {
SkPoint points[5] = {{0, SkIntToScalar(-50)} };
SkMatrix rot;
rot.setRotate(SkIntToScalar(360) / 5);
for (int i = 1; i < 5; ++i) {
rot.mapPoints(points + i, points + i - 1, 1);
}
fConcavePath.moveTo(points[0]);
for (int i = 0; i < 5; ++i) {
fConcavePath.lineTo(points[(2 * i) % 5]);
}
fConcavePath.setFillType(SkPath::kEvenOdd_FillType);
SkASSERT(!fConcavePath.isConvex());
}
canvas->drawPath(fConcavePath, *paint);
break;
case kText_ShapeType: {
const char* text = "Hello!";
paint->setTextSize(30);
sk_tool_utils::set_portable_typeface(paint);
canvas->drawText(text, strlen(text), 0, 0, *paint);
}
default:
break;
}
}
示例4:
static void test_9patch_rrect(skiatest::Reporter* reporter,
const SkRect& rect,
SkScalar l, SkScalar t, SkScalar r, SkScalar b,
bool checkRadii) {
SkRRect rr;
rr.setNinePatch(rect, l, t, r, b);
REPORTER_ASSERT(reporter, SkRRect::kNinePatch_Type == rr.type());
REPORTER_ASSERT(reporter, rr.rect() == rect);
if (checkRadii) {
// This test doesn't hold if the radii will be rescaled by SkRRect
SkRect ninePatchRadii = { l, t, r, b };
SkPoint rquad[4];
ninePatchRadii.toQuad(rquad);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, rquad[i] == rr.radii((SkRRect::Corner) i));
}
}
SkRRect rr2; // construct the same RR using the most general set function
SkVector radii[4] = { { l, t }, { r, t }, { r, b }, { l, b } };
rr2.setRectRadii(rect, radii);
REPORTER_ASSERT(reporter, rr2 == rr && rr2.getType() == rr.getType());
}