Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / docs / examples / TextBlob_getIntercepts.cpp
1 #if 0  // Disabled until updated to use current API.
2 // Copyright 2019 Google LLC.
3 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4 #include "tools/fiddle/examples.h"
5 // HASH=e9d4eb8ece521b1329e7433d4b243fdf
6 REG_FIDDLE(TextBlob_getIntercepts, 256, 143, false, 0) {
7 void draw(SkCanvas* canvas) {
8     SkFont font;
9     font.setSize(120);
10     SkPoint textPos = { 20, 110 };
11     int len = 3;
12     SkTextBlobBuilder textBlobBuilder;
13     const SkTextBlobBuilder::RunBuffer& run =
14             textBlobBuilder.allocRun(font, len, textPos.fX, textPos.fY);
15     run.glyphs[0] = 10;
16     run.glyphs[1] = 20;
17     run.glyphs[2] = 30;
18     sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
19     SkPaint paint;
20     SkScalar bounds[] = { 116, 134 };
21     int count = blob->getIntercepts(bounds, nullptr);
22     std::vector<SkScalar> intervals;
23     intervals.resize(count);
24     (void) paint.getTextBlobIntercepts(blob.get(), bounds, &intervals.front());
25     canvas->drawTextBlob(blob.get(), 0, 0, paint);
26     paint.setColor(0xFFFF7777);
27     SkScalar x = textPos.fX;
28     for (int i = 0; i < count; i+= 2) {
29         canvas->drawRect({x, bounds[0], intervals[i], bounds[1]}, paint);
30         x = intervals[i + 1];
31     }
32     canvas->drawRect({intervals[count - 1], bounds[0], 180, bounds[1]}, paint);
33 }
34 }  // END FIDDLE
35 #endif  // Disabled until updated to use current API.