Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 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 "fiddle/examples.h" |
| 5 | // HASH=0bc7b3997357e499817278b78bdfbf1d |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame^] | 6 | REG_FIDDLE(Point_cross, 256, 256, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 7 | void draw(SkCanvas* canvas) { |
| 8 | SkPaint paint; |
| 9 | paint.setAntiAlias(true); |
| 10 | SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, |
| 11 | {{-20, -24}, {-24, -20}}}; |
| 12 | SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; |
| 13 | paint.setStrokeWidth(2); |
| 14 | for (size_t i = 0; i < 4; ++i) { |
| 15 | paint.setColor(SK_ColorRED); |
| 16 | canvas->drawLine(center[i], center[i] + vectors[i][0], paint); |
| 17 | paint.setColor(SK_ColorBLUE); |
| 18 | canvas->drawLine(center[i], center[i] + vectors[i][1], paint); |
| 19 | SkString str; |
| 20 | SkScalar cross = vectors[i][0].cross(vectors[i][1]); |
| 21 | str.printf("cross = %g", cross); |
| 22 | paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE); |
| 23 | canvas->drawString(str, center[i].fX, center[i].fY, paint); |
| 24 | } |
| 25 | } |
| 26 | } // END FIDDLE |
| 27 | #endif // Disabled until updated to use current API. |