diff options
author | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-08 11:47:37 +0000 |
---|---|---|
committer | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-08 11:47:37 +0000 |
commit | 07393cab57ce74a4aae89a31fae9aaa9780fc19d (patch) | |
tree | 2923009427914f3da107d4797e7e7fd2b9266f9a /src/pathops/SkPathOpsLine.h | |
parent | 390c6d7a9018e233a6519397ac6c739fb21a99ef (diff) |
Add base types for path ops
Paths contain lines, quads, and cubics, which are
collectively curves.
To work with path intersections, intermediary curves
are constructed. For now, those intermediates use
doubles to guarantee sufficient precision.
The DVector, DPoint, DLine, DQuad, and DCubic
structs encapsulate these intermediate curves.
The DRect and DTriangle structs are created to
describe intersectable areas of interest.
The Bounds struct inherits from SkRect to create
a SkScalar-based rectangle that intersects shared
edges.
This also includes common math equalities and
debugging that the remainder of path ops builds on,
as well as a temporary top-level interface in
include/pathops/SkPathOps.h.
Review URL: https://codereview.chromium.org/12827020
git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pathops/SkPathOpsLine.h')
-rw-r--r-- | src/pathops/SkPathOpsLine.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/pathops/SkPathOpsLine.h b/src/pathops/SkPathOpsLine.h new file mode 100644 index 0000000000..34bb6587d3 --- /dev/null +++ b/src/pathops/SkPathOpsLine.h @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef SkPathOpsLine_DEFINED +#define SkPathOpsLine_DEFINED + +#include "SkPathOpsPoint.h" + +struct SkDLine { + SkDPoint fPts[2]; + + void set(const SkPoint pts[2]) { + fPts[0] = pts[0]; + fPts[1] = pts[1]; + } + + const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 2); return fPts[n]; } + SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 2); return fPts[n]; } + + double isLeft(const SkDPoint& pt) const; + SkDLine subDivide(double t1, double t2) const; + static SkDLine SubDivide(const SkPoint a[2], double t1, double t2) { + SkDLine line; + line.set(a); + return line.subDivide(t1, t2); + } + SkDPoint xyAtT(double t) const; +private: + SkDVector tangent() const { return fPts[0] - fPts[1]; } +}; + +#endif |