Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / docs / examples / Point_normalize_2.cpp
1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 // HASH=d84fce292d86c7d9ef37ae2d179c03c7
5 REG_FIDDLE(Point_normalize_2, 256, 256, false, 0) {
6 void draw(SkCanvas* canvas) {
7     SkPaint paint;
8     paint.setAntiAlias(true);
9     const SkPoint lines[][2] = { {{  30, 110 }, { 190,  30 }},
10                                  {{ 120, 140 }, {  30, 220 }}};
11     for (auto line : lines) {
12         canvas->drawLine(line[0], line[1], paint);
13         SkVector vector = line[1] - line[0];
14         if (vector.normalize()) {
15             SkVector rotate90 = { -vector.fY, vector.fX };
16             rotate90 *= 10.f;
17             canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint);
18             canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint);
19         }
20     }
21 }
22 }  // END FIDDLE