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


C++ SkRegion::setRects方法代码示例

本文整理汇总了C++中SkRegion::setRects方法的典型用法代码示例。如果您正苦于以下问题:C++ SkRegion::setRects方法的具体用法?C++ SkRegion::setRects怎么用?C++ SkRegion::setRects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkRegion的用法示例。


在下文中一共展示了SkRegion::setRects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: filter

DEF_TEST(FlattenableFactoryToName, r) {
    SkIRect rects[2];
    rects[0] = SkIRect::MakeXYWH(0, 150, 500, 200);
    rects[1] = SkIRect::MakeXYWH(150, 0, 200, 500);
    SkRegion region;
    region.setRects(rects, 2);
    sk_sp<SkImageFilter> filter(SkAlphaThresholdFilter::Make(region, 0.2f, 0.7f, nullptr));
    test_flattenable(r, filter.get(), "SkAlphaThresholdFilter()");

    SkBitmap bm;
    bm.allocN32Pixels(8, 8);
    bm.eraseColor(SK_ColorCYAN);
    sk_sp<SkImage> image(SkImage::MakeFromBitmap(bm));
    auto shader = image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
    test_flattenable(r, shader.get(), "SkImage::newShader()");
}
开发者ID:03050903,项目名称:skia,代码行数:16,代码来源:FlattenableFactoryToName.cpp

示例2: emit_clip

// TODO: expand the testing to include the different ops & AA types!
static void emit_clip(SkCanvas* canvas, ClipType clip) {
    switch (clip) {
        case kNone_ClipType:
            break;
        case kRect_ClipType: {
            SkRect r = SkRect::MakeLTRB(10, 10, 90, 90);
            canvas->clipRect(r, SkRegion::kIntersect_Op, true);
            break;
        }
        case kRRect_ClipType: {
            SkRect r = SkRect::MakeLTRB(10, 10, 90, 90);
            SkRRect rr;
            rr.setRectXY(r, 10, 10);
            canvas->clipRRect(rr, SkRegion::kIntersect_Op, true);
            break;
        }
        case kPath_ClipType: {
            SkPath p;
            p.moveTo(5.0f, 5.0f);
            p.lineTo(50.0f, 50.0f);
            p.lineTo(100.0f, 5.0f);
            p.close();
            canvas->clipPath(p, SkRegion::kIntersect_Op, true);
            break;
        }
        case kRegion_ClipType: {
            SkIRect rects[2] = {
                { 1, 1, 55, 55 },
                { 45, 45, 99, 99 },
            };
            SkRegion r;
            r.setRects(rects, 2);
            canvas->clipRegion(r, SkRegion::kIntersect_Op);
            break;
        }
        default:
            SkASSERT(0);
    }
}
开发者ID:03050903,项目名称:skia,代码行数:40,代码来源:MatrixClipCollapseTest.cpp

示例3: onDraw

    void onDraw(SkCanvas* canvas) override {
        SkIRect rects[2];
        rects[0] = SkIRect::MakeXYWH(0, 150, WIDTH, HEIGHT - 300);
        rects[1] = SkIRect::MakeXYWH(150, 0, WIDTH - 300, HEIGHT);
        SkRegion region;
        region.setRects(rects, 2);

        SkMatrix matrix;
        matrix.reset();
        matrix.setTranslate(WIDTH * .1f, HEIGHT * .1f);
        matrix.postScale(.8f, .8f);

        canvas->concat(matrix);

        SkPaint paint;
        paint.setImageFilter(
            SkAlphaThresholdFilter::Create(region, 0.2f, 0.7f))->unref();
        canvas->saveLayer(nullptr, &paint);
        paint.setAntiAlias(true);

        SkPaint rect_paint;
        rect_paint.setColor(0xFF0000FF);
        canvas->drawRect(SkRect::MakeXYWH(0, 0, WIDTH / 2, HEIGHT / 2),
                         rect_paint);
        rect_paint.setColor(0xBFFF0000);
        canvas->drawRect(SkRect::MakeXYWH(WIDTH / 2, 0, WIDTH / 2, HEIGHT / 2),
                         rect_paint);
        rect_paint.setColor(0x3F00FF00);
        canvas->drawRect(SkRect::MakeXYWH(0, HEIGHT / 2, WIDTH / 2, HEIGHT / 2),
                         rect_paint);
        rect_paint.setColor(0x00000000);
        canvas->drawRect(SkRect::MakeXYWH(WIDTH / 2, HEIGHT / 2, WIDTH / 2, HEIGHT / 2),
                         rect_paint);

        canvas->restore();
    }
开发者ID:Crawping,项目名称:chromium_extract,代码行数:36,代码来源:imagealphathreshold.cpp


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