diff options
Diffstat (limited to 'include/core/SkGeometry.h')
-rw-r--r-- | include/core/SkGeometry.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/core/SkGeometry.h b/include/core/SkGeometry.h index 853a7c34a5..b8ab74caef 100644 --- a/include/core/SkGeometry.h +++ b/include/core/SkGeometry.h @@ -20,6 +20,17 @@ #include "SkMatrix.h" +/** An XRay is a half-line that runs from the specific point/origin to + +infinity in the X direction. e.g. XRay(3,5) is the half-line + (3,5)....(infinity, 5) + */ +typedef SkPoint SkXRay; + +/** Given a line segment from pts[0] to pts[1], and ax xray, return true if + they intersect. +*/ +bool SkXRayCrossesLine(const SkXRay& pt, const SkPoint pts[2]); + /** Given a quadratic equation Ax^2 + Bx + C = 0, return 0, 1, 2 roots for the equation. */ @@ -72,6 +83,12 @@ int SkChopQuadAtXExtrema(const SkPoint src[3], SkPoint dst[5]); */ int SkChopQuadAtMaxCurvature(const SkPoint src[3], SkPoint dst[5]); +/** Given 3 points on a quadratic bezier, use degree elevation to + convert it into the cubic fitting the same curve. The new cubic + curve is returned in dst[0..3]. +*/ +void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4]); + //////////////////////////////////////////////////////////////////////////////////////// /** Convert from parametric from (pts) to polynomial coefficients @@ -131,6 +148,26 @@ int SkChopCubicAtInflections(const SkPoint src[4], SkPoint dst[10]); int SkFindCubicMaxCurvature(const SkPoint src[4], SkScalar tValues[3]); int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], SkScalar tValues[3] = NULL); +/** Given a monotonic cubic bezier, determine whether an xray intersects the + cubic. + By definition the cubic is open at the starting point; in other + words, if pt.fY is equivalent to cubic[0].fY, and pt.fX is to the + left of the curve, the line is not considered to cross the curve, + but if it is equal to cubic[3].fY then it is considered to + cross. + */ +bool SkXRayCrossesMonotonicCubic(const SkXRay& pt, const SkPoint cubic[4]); + +/** Given an arbitrary cubic bezier, return the number of times an xray crosses + the cubic. Valid return values are [0..3] + By definition the cubic is open at the starting point; in other + words, if pt.fY is equivalent to cubic[0].fY, and pt.fX is to the + left of the curve, the line is not considered to cross the curve, + but if it is equal to cubic[3].fY then it is considered to + cross. + */ +int SkNumXRayCrossingsForCubic(const SkXRay& pt, const SkPoint cubic[4]); + /////////////////////////////////////////////////////////////////////////////////////////// enum SkRotationDirection { |