From 0c5f54663b3080819825bd035979a82d4c5ac902 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Fri, 15 Dec 2017 11:21:51 -0500 Subject: working on image docs some new image work turn dos into unix linefeeds add SkBitmap::pixmap() Docs-Preview: https://skia.org/?cl=83863 TBR=caryclark@google.com Bug: skia:6898 Change-Id: I06242b4b66464814b753fe37f930baf32f79323a Reviewed-on: https://skia-review.googlesource.com/83863 Reviewed-by: Cary Clark Commit-Queue: Cary Clark --- docs/SkPoint_Reference.bmh | 784 ++++++++++++++++++++++----------------------- 1 file changed, 392 insertions(+), 392 deletions(-) (limited to 'docs/SkPoint_Reference.bmh') diff --git a/docs/SkPoint_Reference.bmh b/docs/SkPoint_Reference.bmh index bac5186f3b..6eeb1a5703 100644 --- a/docs/SkPoint_Reference.bmh +++ b/docs/SkPoint_Reference.bmh @@ -152,12 +152,12 @@ Returns true if fX and fY are both zero. #Return true if fX is zero and fY is zero ## #Example -SkPoint pt = { 0.f, -0.f}; -SkDebugf("pt.fX=%c%g pt.fY=%c%g\n", std::signbit(pt.fX) ? '-' : '+', fabsf(pt.fX), - std::signbit(pt.fY) ? '-' : '+', fabsf(pt.fY)); +SkPoint pt = { 0.f, -0.f}; +SkDebugf("pt.fX=%c%g pt.fY=%c%g\n", std::signbit(pt.fX) ? '-' : '+', fabsf(pt.fX), + std::signbit(pt.fY) ? '-' : '+', fabsf(pt.fY)); SkDebugf("pt.isZero() == %s\n", pt.isZero() ? "true" : "false"); #StdOut -pt.fX=+0 pt.fY=-0 +pt.fX=+0 pt.fY=-0 pt.isZero() == true ## ## @@ -202,8 +202,8 @@ casts x and y to avoid the error. #Param y new value for fY ## #Example -SkPoint pt1, pt2 = { SK_MinS16, SK_MaxS16 }; -pt1.iset(SK_MinS16, SK_MaxS16); +SkPoint pt1, pt2 = { SK_MinS16, SK_MaxS16 }; +pt1.iset(SK_MinS16, SK_MaxS16); SkDebugf("pt1 %c= pt2\n", pt1 == pt2 ? '=' : '!'); ## @@ -224,13 +224,13 @@ This safely casts p.fX and p.fY to avoid the error. #Param p IPoint members promoted to SkScalar ## #Example -SkIPoint iPt = { SK_MinS32, SK_MaxS32 }; -SkPoint fPt; -fPt.iset(iPt); +SkIPoint iPt = { SK_MinS32, SK_MaxS32 }; +SkPoint fPt; +fPt.iset(iPt); SkDebugf("iPt: %d, %d\n", iPt.fX, iPt.fY); SkDebugf("fPt: %g, %g\n", fPt.fX, fPt.fY); #StdOut -iPt: -2147483647, 2147483647 +iPt: -2147483647, 2147483647 fPt: -2.14748e+09, 2.14748e+09 ## ## @@ -248,18 +248,18 @@ Sets fX to absolute value of pt.fX; and fY to absolute value of pt.fY. #Param pt members providing magnitude for fX and fY ## #Example -SkPoint test[] = { {0.f, -0.f}, {-1, -2}, - { SK_ScalarInfinity, SK_ScalarNegativeInfinity }, - { SK_ScalarNaN, -SK_ScalarNaN } }; -for (const SkPoint& pt : test) { - SkPoint absPt; - absPt.setAbs(pt); - SkDebugf("pt: %g, %g abs: %g, %g\n", pt.fX, pt.fY, absPt.fX, absPt.fY); +SkPoint test[] = { {0.f, -0.f}, {-1, -2}, + { SK_ScalarInfinity, SK_ScalarNegativeInfinity }, + { SK_ScalarNaN, -SK_ScalarNaN } }; +for (const SkPoint& pt : test) { + SkPoint absPt; + absPt.setAbs(pt); + SkDebugf("pt: %g, %g abs: %g, %g\n", pt.fX, pt.fY, absPt.fX, absPt.fY); } #StdOut -pt: 0, -0 abs: 0, 0 -pt: -1, -2 abs: 1, 2 -pt: inf, -inf abs: inf, inf +pt: 0, -0 abs: 0, 0 +pt: -1, -2 abs: 1, 2 +pt: inf, -inf abs: inf, inf pt: nan, -nan abs: nan, nan ## ## @@ -279,17 +279,17 @@ Adds offset to each Point in points array with count entries. #Param offset Vector added to points ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(30, 15); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - SkPoint::Offset(points, SK_ARRAY_COUNT(points), { 1, 9 } ); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(30, 15); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPoint::Offset(points, SK_ARRAY_COUNT(points), { 1, 9 } ); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso offset operator+=(const SkVector& v) @@ -308,17 +308,17 @@ Adds offset (dx, dy) to each Point in points array of length count. #Param dy added to fY in points ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(30, 15); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - SkPoint::Offset(points, SK_ARRAY_COUNT(points), 1, 9); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(30, 15); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPoint::Offset(points, SK_ARRAY_COUNT(points), 1, 9); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso offset operator+=(const SkVector& v) @@ -336,18 +336,18 @@ Adds offset (dx, dy) to Point. #Example #Height 128 - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(30, 15); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - points[1].offset(1, 1); - paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(30, 15); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + points[1].offset(1, 1); + paint.setColor(SK_ColorRED); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso Offset operator+=(const SkVector& v) @@ -369,19 +369,19 @@ sqrt(fX * fX + fY * fY) #Example #Height 192 - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint points[] = { { 90, 30 }, { 120, 150 }, { 150, 30 }, { 210, 90 } }; - const SkPoint origin = {30, 140}; - for (auto point : points) { - canvas->drawLine(origin, point, paint); - SkAutoCanvasRestore acr(canvas, true); - SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX); - canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY); - SkString length("length = "); - length.appendScalar(point.length()); - canvas->drawString(length, origin.fX + 25, origin.fY - 4, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint points[] = { { 90, 30 }, { 120, 150 }, { 150, 30 }, { 210, 90 } }; + const SkPoint origin = {30, 140}; + for (auto point : points) { + canvas->drawLine(origin, point, paint); + SkAutoCanvasRestore acr(canvas, true); + SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX); + canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY); + SkString length("length = "); + length.appendScalar(point.length()); + canvas->drawString(length, origin.fX + 25, origin.fY - 4, paint); + } ## #SeeAlso distanceToOrigin Length setLength Distance @@ -403,20 +403,20 @@ sqrt(fX * fX + fY * fY) #Example #Height 192 - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } }; - const SkPoint origin = {0, 0}; - canvas->translate(30, 140); - for (auto point : points) { - canvas->drawLine(origin, point, paint); - SkAutoCanvasRestore acr(canvas, true); - SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX); - canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY); - SkString distance("distance = "); - distance.appendScalar(point.distanceToOrigin()); - canvas->drawString(distance, origin.fX + 25, origin.fY - 4, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } }; + const SkPoint origin = {0, 0}; + canvas->translate(30, 140); + for (auto point : points) { + canvas->drawLine(origin, point, paint); + SkAutoCanvasRestore acr(canvas, true); + SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX); + canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY); + SkString distance("distance = "); + distance.appendScalar(point.distanceToOrigin()); + canvas->drawString(distance, origin.fX + 25, origin.fY - 4, paint); + } ## #SeeAlso length Length setLength Distance @@ -434,20 +434,20 @@ false; otherwise returns true. #Return true if former length is not zero or nearly zero ## #Example - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint lines[][2] = { {{ 30, 110 }, { 190, 30 }}, - {{ 120, 140 }, { 30, 220 }}}; - for (auto line : lines) { - canvas->drawLine(line[0], line[1], paint); - SkVector vector = line[1] - line[0]; - if (vector.normalize()) { - SkVector rotate90 = { -vector.fY, vector.fX }; - rotate90 *= 10.f; - canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint); - canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint); - } - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint lines[][2] = { {{ 30, 110 }, { 190, 30 }}, + {{ 120, 140 }, { 30, 220 }}}; + for (auto line : lines) { + canvas->drawLine(line[0], line[1], paint); + SkVector vector = line[1] - line[0]; + if (vector.normalize()) { + SkVector rotate90 = { -vector.fY, vector.fX }; + rotate90 *= 10.f; + canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint); + canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint); + } + } ## #SeeAlso Normalize setLength length Length @@ -468,22 +468,22 @@ sets Vector to (0, 0) and returns false; otherwise returns true. #Return true if (x, y) length is not zero or nearly zero ## #Example - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } }; - const SkPoint origin = {0, 0}; - canvas->translate(30, 140); - for (auto point : points) { - paint.setStrokeWidth(1); - paint.setColor(SK_ColorBLACK); - canvas->drawLine(origin, point, paint); - SkVector normal; - normal.setNormalize(point.fX, point.fY); - normal *= 100; - paint.setStrokeWidth(10); - paint.setColor(0x3f4512bf); - canvas->drawLine(origin, normal, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } }; + const SkPoint origin = {0, 0}; + canvas->translate(30, 140); + for (auto point : points) { + paint.setStrokeWidth(1); + paint.setColor(SK_ColorBLACK); + canvas->drawLine(origin, point, paint); + SkVector normal; + normal.setNormalize(point.fX, point.fY); + normal *= 100; + paint.setStrokeWidth(10); + paint.setColor(0x3f4512bf); + canvas->drawLine(origin, normal, paint); + } ## #SeeAlso normalize setLength @@ -504,21 +504,21 @@ true. #Example #Height 160 - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } }; - const SkPoint origin = {0, 0}; - canvas->translate(30, 140); - for (auto point : points) { - paint.setStrokeWidth(1); - paint.setColor(SK_ColorBLACK); - canvas->drawLine(origin, point, paint); - SkVector normal = point; - normal.setLength(100); - paint.setStrokeWidth(10); - paint.setColor(0x3f45bf12); - canvas->drawLine(origin, normal, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } }; + const SkPoint origin = {0, 0}; + canvas->translate(30, 140); + for (auto point : points) { + paint.setStrokeWidth(1); + paint.setColor(SK_ColorBLACK); + canvas->drawLine(origin, point, paint); + SkVector normal = point; + normal.setLength(100); + paint.setStrokeWidth(10); + paint.setColor(0x3f45bf12); + canvas->drawLine(origin, normal, paint); + } ## #SeeAlso length Length setNormalize setAbs @@ -541,21 +541,21 @@ true. #Example #Height 160 - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } }; - const SkPoint origin = {0, 0}; - canvas->translate(30, 140); - for (auto point : points) { - paint.setStrokeWidth(1); - paint.setColor(SK_ColorBLACK); - canvas->drawLine(origin, point, paint); - SkVector normal; - normal.setLength(point.fX, point.fY, 100); - paint.setStrokeWidth(10); - paint.setColor(0x3fbf4512); - canvas->drawLine(origin, normal, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint points[] = { { 60, -110 }, { 90, 10 }, { 120, -110 }, { 180, -50 } }; + const SkPoint origin = {0, 0}; + canvas->translate(30, 140); + for (auto point : points) { + paint.setStrokeWidth(1); + paint.setColor(SK_ColorBLACK); + canvas->drawLine(origin, point, paint); + SkVector normal; + normal.setLength(point.fX, point.fY, 100); + paint.setStrokeWidth(10); + paint.setColor(0x3fbf4512); + canvas->drawLine(origin, normal, paint); + } ## #SeeAlso length Length setNormalize setAbs @@ -572,16 +572,16 @@ Sets dst to Point times scale. dst may be Point to modify Point in place. #Param dst storage for scaled Point ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkPoint point = {40, -15}, scaled; - SkPoint origin = {30, 110}; - for (auto scale : {1, 2, 3, 5}) { - paint.setStrokeWidth(scale * 5); - paint.setARGB(0x7f, 0x9f, 0xbf, 0x33 * scale); - point.scale(scale, &scaled); - canvas->drawLine(origin, origin + scaled, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + SkPoint point = {40, -15}, scaled; + SkPoint origin = {30, 110}; + for (auto scale : {1, 2, 3, 5}) { + paint.setStrokeWidth(scale * 5); + paint.setARGB(0x7f, 0x9f, 0xbf, 0x33 * scale); + point.scale(scale, &scaled); + canvas->drawLine(origin, origin + scaled, paint); + } ## #SeeAlso operator*(SkScalar scale)_const operator*=(SkScalar scale) setLength @@ -597,16 +597,16 @@ Scales Point in place by scale. #Param value factor to multiply Point by ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkPoint point = {40, -15}; - SkPoint origin = {30, 110}; - for (auto scale : {1, 2, 3, 5}) { - paint.setStrokeWidth(scale * 5); - paint.setARGB(0x7f, 0x9f, 0xbf, 0x33 * scale); - point.scale(scale); - canvas->drawLine(origin, origin + point, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + SkPoint point = {40, -15}; + SkPoint origin = {30, 110}; + for (auto scale : {1, 2, 3, 5}) { + paint.setStrokeWidth(scale * 5); + paint.setARGB(0x7f, 0x9f, 0xbf, 0x33 * scale); + point.scale(scale); + canvas->drawLine(origin, origin + point, paint); + } ## #SeeAlso operator*(SkScalar scale)_const operator*=(SkScalar scale) setLength @@ -620,18 +620,18 @@ Scales Point in place by scale. Changes the sign of fX and fY. #Example -SkPoint test[] = { {0.f, -0.f}, {-1, -2}, - { SK_ScalarInfinity, SK_ScalarNegativeInfinity }, - { SK_ScalarNaN, -SK_ScalarNaN } }; -for (const SkPoint& pt : test) { - SkPoint negPt = pt; - negPt.negate(); - SkDebugf("pt: %g, %g negate: %g, %g\n", pt.fX, pt.fY, negPt.fX, negPt.fY); +SkPoint test[] = { {0.f, -0.f}, {-1, -2}, + { SK_ScalarInfinity, SK_ScalarNegativeInfinity }, + { SK_ScalarNaN, -SK_ScalarNaN } }; +for (const SkPoint& pt : test) { + SkPoint negPt = pt; + negPt.negate(); + SkDebugf("pt: %g, %g negate: %g, %g\n", pt.fX, pt.fY, negPt.fX, negPt.fY); } #StdOut -pt: 0, -0 negate: -0, 0 -pt: -1, -2 negate: 1, 2 -pt: inf, -inf negate: -inf, inf +pt: 0, -0 negate: -0, 0 +pt: -1, -2 negate: 1, 2 +pt: inf, -inf negate: -inf, inf pt: nan, -nan negate: -nan, nan ## ## @@ -649,17 +649,17 @@ Returns Point changing the signs of fX and fY. #Return Point as (-fX, -fY) ## #Example -SkPoint test[] = { {0.f, -0.f}, {-1, -2}, - { SK_ScalarInfinity, SK_ScalarNegativeInfinity }, - { SK_ScalarNaN, -SK_ScalarNaN } }; -for (const SkPoint& pt : test) { - SkPoint negPt = -pt; - SkDebugf("pt: %g, %g negate: %g, %g\n", pt.fX, pt.fY, negPt.fX, negPt.fY); +SkPoint test[] = { {0.f, -0.f}, {-1, -2}, + { SK_ScalarInfinity, SK_ScalarNegativeInfinity }, + { SK_ScalarNaN, -SK_ScalarNaN } }; +for (const SkPoint& pt : test) { + SkPoint negPt = -pt; + SkDebugf("pt: %g, %g negate: %g, %g\n", pt.fX, pt.fY, negPt.fX, negPt.fY); } #StdOut -pt: 0, -0 negate: -0, 0 -pt: -1, -2 negate: 1, 2 -pt: inf, -inf negate: -inf, inf +pt: 0, -0 negate: -0, 0 +pt: -1, -2 negate: 1, 2 +pt: inf, -inf negate: -inf, inf pt: nan, -nan negate: -nan, nan ## ## @@ -682,19 +682,19 @@ Adds Vector v to Point. Sets Point to: #Example #Height 128 - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(30, 15); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - points[1] += {1, 1}; - points[2] += {-1, -1}; - paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(30, 15); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + points[1] += {1, 1}; + points[2] += {-1, -1}; + paint.setColor(SK_ColorRED); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso offset() operator+(const SkPoint& a, const SkVector& b) SkIPoint::operator+=(const SkIVector& v) @@ -715,19 +715,19 @@ Subtracts Vector v from Point. Sets Point to: #Example #Height 128 - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(30, 15); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - points[1] -= {1, 1}; - points[2] -= {-1, -1}; - paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(30, 15); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + points[1] -= {1, 1}; + points[2] -= {-1, -1}; + paint.setColor(SK_ColorRED); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso offset() operator-(const SkPoint& a, const SkPoint& b) SkIPoint::operator-=(const SkIVector& v) @@ -746,20 +746,20 @@ Returns Point multiplied by scale. #Example #Height 128 - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(15, 10); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - for (auto& point : points) { - point = point * 1.5f; - } - paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(15, 10); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + for (auto& point : points) { + point = point * 1.5f; + } + paint.setColor(SK_ColorRED); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso operator*=(SkScalar scale) scale() setLength setNormalize @@ -781,20 +781,20 @@ Multiplies Point by scale. Sets Point to: #Example #Height 128 - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(15, 10); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - for (auto& point : points) { - point *= 2; - } - paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(15, 10); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + for (auto& point : points) { + point *= 2; + } + paint.setColor(SK_ColorRED); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso operator*(SkScalar scale)_const scale() setLength setNormalize @@ -810,14 +810,14 @@ Returns true if both fX and fY are measurable values. #Return true for values other than infinities and NaN ## #Example -SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} }; -for (const SkPoint& pt : test) { - SkDebugf("pt: %g, %g finite: %s\n", pt.fX, pt.fY, pt.isFinite() ? "true" : "false"); +SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} }; +for (const SkPoint& pt : test) { + SkDebugf("pt: %g, %g finite: %s\n", pt.fX, pt.fY, pt.isFinite() ? "true" : "false"); } #StdOut -pt: 0, -0 finite: true -pt: -1, -2 finite: true -pt: inf, 1 finite: false +pt: 0, -0 finite: true +pt: -1, -2 finite: true +pt: inf, 1 finite: false pt: nan, -1 finite: false ## ## @@ -838,14 +838,14 @@ Returns true if Point is equivalent to Point constructed from (x, y). #Return true if Point equals (x, y) ## #Example -SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} }; -for (const SkPoint& pt : test) { - SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt.equals(pt.fX, pt.fY) ? '=' : '!'); +SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} }; +for (const SkPoint& pt : test) { + SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt.equals(pt.fX, pt.fY) ? '=' : '!'); } #StdOut -pt: 0, -0 == pt -pt: -1, -2 == pt -pt: inf, 1 == pt +pt: 0, -0 == pt +pt: -1, -2 == pt +pt: inf, 1 == pt pt: nan, -1 != pt ## ## @@ -866,14 +866,14 @@ Returns true if a is equivalent to b. #Return true if a.fX == b.fX and a.fY == b.fY ## #Example -SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} }; -for (const SkPoint& pt : test) { - SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt == pt ? '=' : '!'); +SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} }; +for (const SkPoint& pt : test) { + SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt == pt ? '=' : '!'); } #StdOut -pt: 0, -0 == pt -pt: -1, -2 == pt -pt: inf, 1 == pt +pt: 0, -0 == pt +pt: -1, -2 == pt +pt: inf, 1 == pt pt: nan, -1 != pt ## ## @@ -894,14 +894,14 @@ Returns true if a is not equivalent to b. #Return true if a.fX != b.fX or a.fY != b.fY ## #Example -SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} }; -for (const SkPoint& pt : test) { - SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt != pt ? '!' : '='); +SkPoint test[] = { {0, -0.f}, {-1, -2}, {SK_ScalarInfinity, 1}, {SK_ScalarNaN, -1} }; +for (const SkPoint& pt : test) { + SkDebugf("pt: %g, %g %c= pt\n", pt.fX, pt.fY, pt != pt ? '!' : '='); } #StdOut -pt: 0, -0 == pt -pt: -1, -2 == pt -pt: inf, 1 == pt +pt: 0, -0 == pt +pt: -1, -2 == pt +pt: inf, 1 == pt pt: nan, -1 != pt ## ## @@ -929,19 +929,19 @@ Can also be used to subtract Vector from Vector, returning Vector. #Return Vector from b to a ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(30, 15); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - points[1] += points[0] - points[2]; - points[2] -= points[3] - points[5]; - paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(30, 15); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + points[1] += points[0] - points[2]; + points[2] -= points[3] - points[5]; + paint.setColor(SK_ColorRED); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso operator-=(const SkVector& v) offset() @@ -967,23 +967,23 @@ Can also be used to add Vector to Vector, returning Vector. #Return Point equal to a offset by b ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, - { 6, 4 }, { 7, 5 }, { 5, 7 }, - { 4, 6 }, { 3, 7 }, { 1, 5 }, - { 2, 4 }, { 1, 3 }, { 3, 1 } }; - canvas->scale(30, 15); - paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - SkVector mod = {1, 1}; - for (auto& point : points) { - point = point + mod; - mod.fX *= 1.1f; - mod.fY += .2f; - } - paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkPaint paint; + paint.setAntiAlias(true); + SkPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 }, + { 6, 4 }, { 7, 5 }, { 5, 7 }, + { 4, 6 }, { 3, 7 }, { 1, 5 }, + { 2, 4 }, { 1, 3 }, { 3, 1 } }; + canvas->scale(30, 15); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + SkVector mod = {1, 1}; + for (auto& point : points) { + point = point + mod; + mod.fX *= 1.1f; + mod.fY += .2f; + } + paint.setColor(SK_ColorRED); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); ## #SeeAlso operator+=(const SkVector& v) offset() @@ -1008,19 +1008,19 @@ sqrt(x * x + y * y) #Example #Height 192 - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint points[] = { { 90, 30 }, { 120, 150 }, { 150, 30 }, { 210, 90 } }; - const SkPoint origin = {30, 140}; - for (auto point : points) { - canvas->drawLine(origin, point, paint); - SkAutoCanvasRestore acr(canvas, true); - SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX); - canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY); - SkString length("length = "); - length.appendScalar(SkPoint::Length(point.fX, point.fY)); - canvas->drawString(length, origin.fX + 25, origin.fY - 4, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint points[] = { { 90, 30 }, { 120, 150 }, { 150, 30 }, { 210, 90 } }; + const SkPoint origin = {30, 140}; + for (auto point : points) { + canvas->drawLine(origin, point, paint); + SkAutoCanvasRestore acr(canvas, true); + SkScalar angle = SkScalarATan2((point.fY - origin.fY), point.fX - origin.fX); + canvas->rotate(angle * 180 / SK_ScalarPI, origin.fX, origin.fY); + SkString length("length = "); + length.appendScalar(SkPoint::Length(point.fX, point.fY)); + canvas->drawString(length, origin.fX + 25, origin.fY - 4, paint); + } ## #SeeAlso length() Distance setLength @@ -1044,22 +1044,22 @@ Note that normalize() is faster if prior length is not required. #Return original vec length ## #Example - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint lines[][2] = { {{ 30, 110 }, { 190, 30 }}, - {{ 30, 220 }, { 120, 140 }}}; - for (auto line : lines) { - canvas->drawLine(line[0], line[1], paint); - SkVector vector = line[1] - line[0]; - SkScalar priorLength = SkPoint::Normalize(&vector); - SkVector rotate90 = { -vector.fY, vector.fX }; - rotate90 *= 10.f; - canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint); - canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint); - SkString length("length = "); - length.appendScalar(priorLength); - canvas->drawString(length, line[0].fX + 25, line[0].fY - 4, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint lines[][2] = { {{ 30, 110 }, { 190, 30 }}, + {{ 30, 220 }, { 120, 140 }}}; + for (auto line : lines) { + canvas->drawLine(line[0], line[1], paint); + SkVector vector = line[1] - line[0]; + SkScalar priorLength = SkPoint::Normalize(&vector); + SkVector rotate90 = { -vector.fY, vector.fX }; + rotate90 *= 10.f; + canvas->drawLine(line[0] - rotate90, line[0] + rotate90, paint); + canvas->drawLine(line[1] - rotate90, line[1] + rotate90, paint); + SkString length("length = "); + length.appendScalar(priorLength); + canvas->drawString(length, line[0].fX + 25, line[0].fY - 4, paint); + } ## #SeeAlso normalize() setLength Length @@ -1079,21 +1079,21 @@ Returns the Euclidean_Distance between a and b. #Example #Height 192 - SkPaint paint; - paint.setAntiAlias(true); - const SkPoint lines[][2] = {{{-10, -10}, {90, 30}}, {{0, 0}, {150, 30}}, {{10, 25}, {120, 150}}}; - const SkPoint origin = {30, 160}; - for (auto line : lines) { - SkPoint a = origin + line[0]; - const SkPoint& b = line[1]; - canvas->drawLine(a, b, paint); - SkAutoCanvasRestore acr(canvas, true); - SkScalar angle = SkScalarATan2((b.fY - a.fY), b.fX - a.fX); - canvas->rotate(angle * 180 / SK_ScalarPI, a.fX, a.fY); - SkString distance("distance = "); - distance.appendScalar(SkPoint::Distance(a, b)); - canvas->drawString(distance, a.fX + 25, a.fY - 4, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + const SkPoint lines[][2] = {{{-10, -10}, {90, 30}}, {{0, 0}, {150, 30}}, {{10, 25}, {120, 150}}}; + const SkPoint origin = {30, 160}; + for (auto line : lines) { + SkPoint a = origin + line[0]; + const SkPoint& b = line[1]; + canvas->drawLine(a, b, paint); + SkAutoCanvasRestore acr(canvas, true); + SkScalar angle = SkScalarATan2((b.fY - a.fY), b.fX - a.fX); + canvas->rotate(angle * 180 / SK_ScalarPI, a.fX, a.fY); + SkString distance("distance = "); + distance.appendScalar(SkPoint::Distance(a, b)); + canvas->drawString(distance, a.fX + 25, a.fY - 4, paint); + } ## #SeeAlso length() setLength @@ -1112,19 +1112,19 @@ Returns the dot product of Vector a and Vector b. #Return product of input magnitudes and cosine of the angle between them ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, - {{-20, -24}, {-24, -20}}}; - SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; - paint.setStrokeWidth(2); - for (size_t i = 0; i < 4; ++i) { - canvas->drawLine(center[i], center[i] + vectors[i][0], paint); - canvas->drawLine(center[i], center[i] + vectors[i][1], paint); - SkString str; - str.printf("dot = %g", SkPoint::DotProduct(vectors[i][0], vectors[i][1])); - canvas->drawString(str, center[i].fX, center[i].fY, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, + {{-20, -24}, {-24, -20}}}; + SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; + paint.setStrokeWidth(2); + for (size_t i = 0; i < 4; ++i) { + canvas->drawLine(center[i], center[i] + vectors[i][0], paint); + canvas->drawLine(center[i], center[i] + vectors[i][1], paint); + SkString str; + str.printf("dot = %g", SkPoint::DotProduct(vectors[i][0], vectors[i][1])); + canvas->drawString(str, center[i].fX, center[i].fY, paint); + } ## #SeeAlso dot CrossProduct @@ -1147,23 +1147,23 @@ term equals the returned value. #Return area spanned by Vectors signed by angle direction ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, - {{-20, -24}, {-24, -20}}}; - SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; - paint.setStrokeWidth(2); - for (size_t i = 0; i < 4; ++i) { - paint.setColor(SK_ColorRED); - canvas->drawLine(center[i], center[i] + vectors[i][0], paint); - paint.setColor(SK_ColorBLUE); - canvas->drawLine(center[i], center[i] + vectors[i][1], paint); - SkString str; - SkScalar cross = SkPoint::CrossProduct(vectors[i][1], vectors[i][0]); - str.printf("cross = %g", cross); - paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE); - canvas->drawString(str, center[i].fX, center[i].fY, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, + {{-20, -24}, {-24, -20}}}; + SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; + paint.setStrokeWidth(2); + for (size_t i = 0; i < 4; ++i) { + paint.setColor(SK_ColorRED); + canvas->drawLine(center[i], center[i] + vectors[i][0], paint); + paint.setColor(SK_ColorBLUE); + canvas->drawLine(center[i], center[i] + vectors[i][1], paint); + SkString str; + SkScalar cross = SkPoint::CrossProduct(vectors[i][1], vectors[i][0]); + str.printf("cross = %g", cross); + paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE); + canvas->drawString(str, center[i].fX, center[i].fY, paint); + } ## #SeeAlso cross DotProduct @@ -1185,23 +1185,23 @@ The cross product z term equals the returned value. #Return area spanned by Vectors signed by angle direction ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, - {{-20, -24}, {-24, -20}}}; - SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; - paint.setStrokeWidth(2); - for (size_t i = 0; i < 4; ++i) { - paint.setColor(SK_ColorRED); - canvas->drawLine(center[i], center[i] + vectors[i][0], paint); - paint.setColor(SK_ColorBLUE); - canvas->drawLine(center[i], center[i] + vectors[i][1], paint); - SkString str; - SkScalar cross = vectors[i][0].cross(vectors[i][1]); - str.printf("cross = %g", cross); - paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE); - canvas->drawString(str, center[i].fX, center[i].fY, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, + {{-20, -24}, {-24, -20}}}; + SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; + paint.setStrokeWidth(2); + for (size_t i = 0; i < 4; ++i) { + paint.setColor(SK_ColorRED); + canvas->drawLine(center[i], center[i] + vectors[i][0], paint); + paint.setColor(SK_ColorBLUE); + canvas->drawLine(center[i], center[i] + vectors[i][1], paint); + SkString str; + SkScalar cross = vectors[i][0].cross(vectors[i][1]); + str.printf("cross = %g", cross); + paint.setColor(cross >= 0 ? SK_ColorRED : SK_ColorBLUE); + canvas->drawString(str, center[i].fX, center[i].fY, paint); + } ## #SeeAlso CrossProduct dot @@ -1219,19 +1219,19 @@ Returns the dot product of Vector and Vector vec. #Return product of input magnitudes and cosine of the angle between them ## #Example - SkPaint paint; - paint.setAntiAlias(true); - SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, - {{-20, -24}, {-24, -20}}}; - SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; - paint.setStrokeWidth(2); - for (size_t i = 0; i < 4; ++i) { - canvas->drawLine(center[i], center[i] + vectors[i][0], paint); - canvas->drawLine(center[i], center[i] + vectors[i][1], paint); - SkString str; - str.printf("dot = %g", vectors[i][0].dot(vectors[i][1])); - canvas->drawString(str, center[i].fX, center[i].fY, paint); - } + SkPaint paint; + paint.setAntiAlias(true); + SkVector vectors[][2] = {{{50, 2}, {-14, 20}}, {{0, 50}, {-50, 0}}, {{-20, 25}, {25, -20}}, + {{-20, -24}, {-24, -20}}}; + SkPoint center[] = {{32, 32}, {160, 32}, {32, 160}, {160, 160}}; + paint.setStrokeWidth(2); + for (size_t i = 0; i < 4; ++i) { + canvas->drawLine(center[i], center[i] + vectors[i][0], paint); + canvas->drawLine(center[i], center[i] + vectors[i][1], paint); + SkString str; + str.printf("dot = %g", vectors[i][0].dot(vectors[i][1])); + canvas->drawString(str, center[i].fX, center[i].fY, paint); + } ## #SeeAlso DotProduct cross -- cgit v1.2.3