当前位置: 首页>>代码示例>>C++>>正文


C++ SkRect::toQuad方法代码示例

本文整理汇总了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));
    }
}
开发者ID:bunhere,项目名称:skia,代码行数:31,代码来源:techtalk1.cpp

示例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);
 }
开发者ID:achellies,项目名称:DUI_LIb,代码行数:11,代码来源:SampleDraw.cpp

示例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;
     }
 }
开发者ID:03050903,项目名称:skia,代码行数:53,代码来源:dstreadshuffle.cpp

示例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());
}
开发者ID:Arternis,项目名称:skia,代码行数:24,代码来源:RoundRectTest.cpp


注:本文中的SkRect::toQuad方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。