Skia
2DGraphicsLibrary

Public Types  
enum  Side { kLeft_Side = 1, kOn_Side = 0, kRight_Side = 1 } 
The side of a point relative to a line. More...  
Public Member Functions  
SkScalar  x () const 
SkScalar  y () const 
bool  isZero () const 
Returns true iff fX and fY are both zero.  
void  set (SkScalar x, SkScalar y) 
Set the point's X and Y coordinates.  
void  iset (int32_t x, int32_t y) 
Set the point's X and Y coordinates by automatically promoting (x,y) to SkScalar values.  
void  iset (const SkIPoint &p) 
Set the point's X and Y coordinates by automatically promoting p's coordinates to SkScalar values.  
void  setAbs (const SkPoint &pt) 
void  setIRectFan (int l, int t, int r, int b) 
void  setIRectFan (int l, int t, int r, int b, size_t stride) 
void  setRectFan (SkScalar l, SkScalar t, SkScalar r, SkScalar b) 
void  setRectFan (SkScalar l, SkScalar t, SkScalar r, SkScalar b, size_t stride) 
void  offset (SkScalar dx, SkScalar dy) 
SkScalar  length () const 
Return the euclidian distance from (0,0) to the point.  
SkScalar  distanceToOrigin () const 
bool  canNormalize () const 
bool  normalize () 
Set the point (vector) to be unitlength in the same direction as it already points. More...  
bool  setNormalize (SkScalar x, SkScalar y) 
Set the point (vector) to be unitlength in the same direction as the x,y params. More...  
bool  setLength (SkScalar length) 
Scale the point (vector) to have the specified length, and return that length. More...  
bool  setLength (SkScalar x, SkScalar y, SkScalar length) 
Set the point (vector) to have the specified length in the same direction as (x,y). More...  
bool  setLengthFast (SkScalar length) 
Same as setLength, but favoring speed over accuracy.  
bool  setLengthFast (SkScalar x, SkScalar y, SkScalar length) 
Same as setLength, but favoring speed over accuracy.  
void  scale (SkScalar scale, SkPoint *dst) const 
Scale the point's coordinates by scale, writing the answer into dst. More...  
void  scale (SkScalar value) 
Scale the point's coordinates by scale, writing the answer back into the point.  
void  rotateCW (SkPoint *dst) const 
Rotate the point clockwise by 90 degrees, writing the answer into dst. More...  
void  rotateCW () 
Rotate the point clockwise by 90 degrees, writing the answer back into the point.  
void  rotateCCW (SkPoint *dst) const 
Rotate the point counterclockwise by 90 degrees, writing the answer into dst. More...  
void  rotateCCW () 
Rotate the point counterclockwise by 90 degrees, writing the answer back into the point.  
void  negate () 
Negate the point's coordinates.  
SkPoint  operator () const 
Returns a new point whose coordinates are the negative of the point's.  
void  operator+= (const SkPoint &v) 
Add v's coordinates to the point's.  
void  operator= (const SkPoint &v) 
Subtract v's coordinates from the point's.  
SkPoint  operator* (SkScalar scale) const 
SkPoint &  operator*= (SkScalar scale) 
bool  isFinite () const 
Returns true if both X and Y are finite (not infinity or NaN)  
bool  equals (SkScalar x, SkScalar y) const 
Returns true if the point's coordinates equal (x,y)  
bool  equalsWithinTolerance (const SkPoint &p) const 
Return true if this point and the given point are far enough apart such that a vector between them would be nondegenerate. More...  
bool  equalsWithinTolerance (const SkPoint &p, SkScalar tol) const 
WARNING: There is no guarantee that the result will reflect judgments elsewhere regarding degeneracy ("points A and B are so close that the
vector between them is essentially zero").  
SkScalar  cross (const SkPoint &vec) const 
SkScalar  dot (const SkPoint &vec) const 
SkScalar  lengthSqd () const 
SkScalar  distanceToSqd (const SkPoint &pt) const 
SkScalar  distanceToLineBetweenSqd (const SkPoint &a, const SkPoint &b, Side *side=NULL) const 
Returns the squared distance to the infinite line between two pts. More...  
SkScalar  distanceToLineBetween (const SkPoint &a, const SkPoint &b, Side *side=NULL) const 
Returns the distance to the infinite line between two pts. More...  
SkScalar  distanceToLineSegmentBetweenSqd (const SkPoint &a, const SkPoint &b) const 
Returns the squared distance to the line segment between pts a and b.  
SkScalar  distanceToLineSegmentBetween (const SkPoint &a, const SkPoint &b) const 
Returns the distance to the line segment between pts a and b.  
void  setOrthog (const SkPoint &vec, Side side=kLeft_Side) 
Make this vector be orthogonal to vec. More...  
const SkScalar *  asScalars () const 
castsafe way to treat the point as an array of (2) SkScalars.  
Static Public Member Functions  
static SkPoint  Make (SkScalar x, SkScalar y) 
static void  Offset (SkPoint points[], int count, const SkPoint &offset) 
static void  Offset (SkPoint points[], int count, SkScalar dx, SkScalar dy) 
static bool  CanNormalize (SkScalar dx, SkScalar dy) 
Return true if the computed length of the vector is >= the internal tolerance (used to avoid dividing by tiny values).  
static SkScalar  Length (SkScalar x, SkScalar y) 
Returns the euclidian distance from (0,0) to (x,y)  
static SkScalar  Normalize (SkPoint *pt) 
Normalize pt, returning its previous length. More...  
static SkScalar  Distance (const SkPoint &a, const SkPoint &b) 
Returns the euclidian distance between a and b.  
static SkScalar  DotProduct (const SkPoint &a, const SkPoint &b) 
Returns the dot product of a and b, treating them as 2D vectors.  
static SkScalar  CrossProduct (const SkPoint &a, const SkPoint &b) 
Returns the cross product of a and b, treating them as 2D vectors.  
Public Attributes  
SkScalar  fX 
SkScalar  fY 
Friends  
bool  operator== (const SkPoint &a, const SkPoint &b) 
bool  operator!= (const SkPoint &a, const SkPoint &b) 
SkPoint  operator (const SkPoint &a, const SkPoint &b) 
Returns a new point whose coordinates are the difference between a's and b's (a  b)  
SkPoint  operator+ (const SkPoint &a, const SkPoint &b) 
Returns a new point whose coordinates are the sum of a's and b's (a + b)  
enum SkPoint::Side 
The side of a point relative to a line.
If the line is from a to b then the values are consistent with the sign of (ba) cross (pta)

inline 
Returns the distance to the infinite line between two pts.
Also optionally returns the side of the line that the pt falls on (looking along the line from a to b)
SkScalar SkPoint::distanceToLineBetweenSqd  (  const SkPoint &  a, 
const SkPoint &  b,  
Side *  side = NULL 

)  const 
Returns the squared distance to the infinite line between two pts.
Also optionally returns the side of the line that the pt falls on (looking along line from a to b)

inline 
Return true if this point and the given point are far enough apart such that a vector between them would be nondegenerate.
WARNING: Unlike the explicit tolerance version, this method does not use componentwise comparison. Instead, it uses a comparison designed to match judgments elsewhere regarding degeneracy ("points A and B are so close that the vector between them is essentially zero").
bool SkPoint::normalize  (  ) 
Set the point (vector) to be unitlength in the same direction as it already points.
If the point has a degenerate length (i.e. nearly 0) then set it to (0,0) and return false; otherwise return true.

static 
Normalize pt, returning its previous length.
If the prev length is too small (degenerate), set pt to (0,0) and return 0. This uses the same tolerance as CanNormalize.
Note that this method may be significantly more expensive than the nonstatic normalize(), because it has to return the previous length of the point. If you don't need the previous length, call the nonstatic normalize() method instead.
void SkPoint::rotateCCW  (  SkPoint *  dst  )  const 
Rotate the point counterclockwise by 90 degrees, writing the answer into dst.
It is legal for dst == this.
void SkPoint::rotateCW  (  SkPoint *  dst  )  const 
Rotate the point clockwise by 90 degrees, writing the answer into dst.
It is legal for dst == this.
void SkPoint::scale  (  SkScalar  scale, 
SkPoint *  dst  
)  const 
Scale the point's coordinates by scale, writing the answer into dst.
It is legal for dst == this.
bool SkPoint::setLength  (  SkScalar  length  ) 
Scale the point (vector) to have the specified length, and return that length.
If the original length is degenerately small (nearly zero), set it to (0,0) and return false, otherwise return true.
bool SkPoint::setLength  (  SkScalar  x, 
SkScalar  y,  
SkScalar  length  
) 
Set the point (vector) to have the specified length in the same direction as (x,y).
If the vector (x,y) has a degenerate length (i.e. nearly 0) then set it to (0,0) and return false, otherwise return true.
bool SkPoint::setNormalize  (  SkScalar  x, 
SkScalar  y  
) 
Set the point (vector) to be unitlength in the same direction as the x,y params.
If the vector (x,y) has a degenerate length (i.e. nearly 0) then set it to (0,0) and return false, otherwise return true.
Make this vector be orthogonal to vec.
Looking down vec the new vector will point in direction indicated by side (which must be kLeft_Side or kRight_Side).