diff options
author | 2012-02-03 22:07:47 +0000 | |
---|---|---|
committer | 2012-02-03 22:07:47 +0000 | |
commit | c682590538a27d73489bc91c098e000fdfb07ccf (patch) | |
tree | 90b03195e3a74cf47f4fa3a385e99575c46da37b /experimental/Intersection/RectUtilities.cpp | |
parent | 2c23708e4478a83dcded2e9d5672bc57ee016919 (diff) |
save work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@3141 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/RectUtilities.cpp')
-rw-r--r-- | experimental/Intersection/RectUtilities.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/experimental/Intersection/RectUtilities.cpp b/experimental/Intersection/RectUtilities.cpp new file mode 100644 index 0000000000..e7bda028ee --- /dev/null +++ b/experimental/Intersection/RectUtilities.cpp @@ -0,0 +1,44 @@ +#include "DataTypes.h" +#include "Extrema.h" + +void _Rect::setBounds(const Cubic& cubic) { + set(cubic[0]); + add(cubic[3]); + double tValues[4]; + int roots = SkFindCubicExtrema(cubic[0].x, cubic[1].x, cubic[2].x, + cubic[3].x, tValues); + roots += SkFindCubicExtrema(cubic[0].y, cubic[1].y, cubic[2].y, cubic[3].y, + &tValues[roots]); + for (int x = 0; x < roots; ++x) { + _Point result; + xy_at_t(cubic, tValues[x], result.x, result.y); + add(result); + } +} + +void _Rect::setRawBounds(const Cubic& cubic) { + set(cubic[0]); + for (int x = 1; x < 4; ++x) { + add(cubic[x]); + } +} + +void _Rect::setBounds(const Quadratic& quad) { + set(quad[0]); + add(quad[2]); + double tValues[2]; + int roots = SkFindQuadExtrema(quad[0].x, quad[1].x, quad[2].x, tValues); + roots += SkFindQuadExtrema(quad[0].y, quad[1].y, quad[2].y, &tValues[roots]); + for (int x = 0; x < roots; ++x) { + _Point result; + xy_at_t(quad, tValues[x], result.x, result.y); + add(result); + } +} + +void _Rect::setRawBounds(const Quadratic& quad) { + set(quad[0]); + for (int x = 1; x < 3; ++x) { + add(quad[x]); + } +} |