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


C++ SkRandom::nextBits方法代码示例

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


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

示例1: onDraw

    void onDraw(SkCanvas* canvas) override {
        SkPaint paint;
        paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
        canvas->saveLayer(nullptr, &paint);
        const char* str = "The quick brown fox jumped over the lazy dog.";

        SkRandom rand;
        SkPaint textPaint;
        textPaint.setAntiAlias(true);
        sk_tool_utils::set_portable_typeface(&textPaint);
        for (int i = 0; i < 25; ++i) {
            int x = rand.nextULessThan(WIDTH);
            int y = rand.nextULessThan(HEIGHT);
            textPaint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000));
            textPaint.setTextSize(rand.nextRangeScalar(0, 300));
            canvas->drawText(str, strlen(str), SkIntToScalar(x),
                             SkIntToScalar(y), textPaint);
        }
        canvas->restore();
    }
开发者ID:tiftof,项目名称:skia,代码行数:20,代码来源:imageblur.cpp

示例2: SkIntToScalar

DEF_SIMPLE_GM_BG(imagemagnifier, canvas, WIDTH, HEIGHT, SK_ColorBLACK) {
        SkPaint filterPaint;
        filterPaint.setImageFilter(
            SkMagnifierImageFilter::Make(
                SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100),
                                 SkIntToScalar(WIDTH / 2),
                                 SkIntToScalar(HEIGHT / 2)),
                100, nullptr));
        canvas->saveLayer(nullptr, &filterPaint);
        const char* str = "The quick brown fox jumped over the lazy dog.";
        SkRandom rand;
        for (int i = 0; i < 25; ++i) {
            int x = rand.nextULessThan(WIDTH);
            int y = rand.nextULessThan(HEIGHT);
            SkPaint paint;
            sk_tool_utils::set_portable_typeface(&paint);
            paint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000));
            paint.setTextSize(rand.nextRangeScalar(0, 300));
            paint.setAntiAlias(true);
            canvas->drawText(str, strlen(str), SkIntToScalar(x),
                             SkIntToScalar(y), paint);
        }
        canvas->restore();
}
开发者ID:03050903,项目名称:skia,代码行数:24,代码来源:imagemagnifier.cpp

示例3: onDraw

 void onDraw(SkCanvas* canvas) override {
     SkPaint filterPaint;
     filterPaint.setImageFilter(
         SkMagnifierImageFilter::Create(
             SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100),
                              SkIntToScalar(WIDTH / 2),
                              SkIntToScalar(HEIGHT / 2)),
             100))->unref();
     canvas->saveLayer(NULL, &filterPaint);
     const char* str = "The quick brown fox jumped over the lazy dog.";
     SkRandom rand;
     for (int i = 0; i < 25; ++i) {
         int x = rand.nextULessThan(WIDTH);
         int y = rand.nextULessThan(HEIGHT);
         SkPaint paint;
         sk_tool_utils::set_portable_typeface(&paint);
         paint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000));
         paint.setTextSize(rand.nextRangeScalar(0, 300));
         paint.setAntiAlias(true);
         canvas->drawText(str, strlen(str), SkIntToScalar(x),
                          SkIntToScalar(y), paint);
     }
     canvas->restore();
 }
开发者ID:nikolayvoronchikhin,项目名称:skia,代码行数:24,代码来源:imagemagnifier.cpp


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