aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-01-28 21:34:33 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-01-28 21:34:33 +0000
commitac753098e8af4a17e5df97b3a4dd0ce123f8d70c (patch)
tree91274eee1dcda52ebe6233f24c71cf8c4394ecb0 /include/core
parent2736a69077af6016f71ecbb2bb98e311aea0da01 (diff)
add some utils to SkPoint
git-svn-id: http://skia.googlecode.com/svn/trunk@485 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkPoint.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/include/core/SkPoint.h b/include/core/SkPoint.h
index d23f696334..bdb30d99ee 100644
--- a/include/core/SkPoint.h
+++ b/include/core/SkPoint.h
@@ -26,6 +26,12 @@
*/
struct SkIPoint {
int32_t fX, fY;
+
+ static SkIPoint Make(int32_t x, int32_t y) {
+ SkIPoint pt;
+ pt.set(x, y);
+ return pt;
+ }
/** Set the x and y values of the point. */
void set(int32_t x, int32_t y) { fX = x; fY = y; }
@@ -122,6 +128,12 @@ struct SkIPoint {
struct SkPoint {
SkScalar fX, fY;
+ static SkPoint Make(SkScalar x, SkScalar y) {
+ SkPoint pt;
+ pt.set(x, y);
+ return pt;
+ }
+
/** Set the point's X and Y coordinates */
void set(SkScalar x, SkScalar y) { fX = x; fY = y; }
@@ -262,7 +274,12 @@ struct SkPoint {
/** Returns the euclidian distance from (0,0) to (x,y)
*/
static SkScalar Length(SkScalar x, SkScalar y);
-
+
+ /** Normalize pt, returning its previous length. If the prev length is too
+ small (degenerate), return 0 and leave pt unchanged.
+ */
+ static SkScalar Normalize(SkPoint* pt);
+
/** Returns the euclidian distance between a and b
*/
static SkScalar Distance(const SkPoint& a, const SkPoint& b) {