aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/LineCubicIntersection.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-14 15:29:11 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-14 15:29:11 +0000
commit45a8fc6a8b00451f807783f2a6ec640e9bcc7256 (patch)
treebf483ee177b764a83768534293b9542a5a0c036e /experimental/Intersection/LineCubicIntersection.cpp
parent3976825a21532e254311b90b4a9046e25717e335 (diff)
shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@7738 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/LineCubicIntersection.cpp')
-rw-r--r--experimental/Intersection/LineCubicIntersection.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/experimental/Intersection/LineCubicIntersection.cpp b/experimental/Intersection/LineCubicIntersection.cpp
index faed89fe91..1e97ab27fa 100644
--- a/experimental/Intersection/LineCubicIntersection.cpp
+++ b/experimental/Intersection/LineCubicIntersection.cpp
@@ -107,7 +107,9 @@ int intersect() {
double cubicT = rootVals[index];
double lineT = findLineT(cubicT);
if (pinTs(cubicT, lineT)) {
- intersections.insert(cubicT, lineT);
+ _Point pt;
+ xy_at_t(line, lineT, pt.x, pt.y);
+ intersections.insert(cubicT, lineT, pt);
}
}
return intersections.fUsed;
@@ -125,12 +127,12 @@ int horizontalIntersect(double axisIntercept, double left, double right, bool fl
double rootVals[3];
int roots = horizontalIntersect(axisIntercept, rootVals);
for (int index = 0; index < roots; ++index) {
- double x;
+ _Point pt;
double cubicT = rootVals[index];
- xy_at_t(cubic, cubicT, x, *(double*) NULL);
- double lineT = (x - left) / (right - left);
+ xy_at_t(cubic, cubicT, pt.x, pt.y);
+ double lineT = (pt.x - left) / (right - left);
if (pinTs(cubicT, lineT)) {
- intersections.insert(cubicT, lineT);
+ intersections.insert(cubicT, lineT, pt);
}
}
if (flipped) {
@@ -151,12 +153,12 @@ int verticalIntersect(double axisIntercept, double top, double bottom, bool flip
double rootVals[3];
int roots = verticalIntersect(axisIntercept, rootVals);
for (int index = 0; index < roots; ++index) {
- double y;
+ _Point pt;
double cubicT = rootVals[index];
- xy_at_t(cubic, cubicT, *(double*) NULL, y);
- double lineT = (y - top) / (bottom - top);
+ xy_at_t(cubic, cubicT, pt.x, pt.y);
+ double lineT = (pt.y - top) / (bottom - top);
if (pinTs(cubicT, lineT)) {
- intersections.insert(cubicT, lineT);
+ intersections.insert(cubicT, lineT, pt);
}
}
if (flipped) {
@@ -172,7 +174,7 @@ void addEndPoints()
for (int cIndex = 0; cIndex < 4; cIndex += 3) {
for (int lIndex = 0; lIndex < 2; lIndex++) {
if (cubic[cIndex] == line[lIndex]) {
- intersections.insert(cIndex >> 1, lIndex);
+ intersections.insert(cIndex >> 1, lIndex, line[lIndex]);
}
}
}
@@ -185,10 +187,10 @@ void addHorizontalEndPoints(double left, double right, double y)
continue;
}
if (cubic[cIndex].x == left) {
- intersections.insert(cIndex >> 1, 0);
+ intersections.insert(cIndex >> 1, 0, cubic[cIndex]);
}
if (cubic[cIndex].x == right) {
- intersections.insert(cIndex >> 1, 1);
+ intersections.insert(cIndex >> 1, 1, cubic[cIndex]);
}
}
}
@@ -200,10 +202,10 @@ void addVerticalEndPoints(double top, double bottom, double x)
continue;
}
if (cubic[cIndex].y == top) {
- intersections.insert(cIndex >> 1, 0);
+ intersections.insert(cIndex >> 1, 0, cubic[cIndex]);
}
if (cubic[cIndex].y == bottom) {
- intersections.insert(cIndex >> 1, 1);
+ intersections.insert(cIndex >> 1, 1, cubic[cIndex]);
}
}
}