skia2/site/user/api/SkPath_Overview.md
Cary Clark cb6bef0ad5 Update bookmaker
- This update includes font documentation.
SkFont_Reference.bmh was generated by running:

  bookmaker -b docs -i include/core/SkFont.h -t

This creates a placeholder
for examples and additional documentation.

- More work done to exclude experimental/private
symbols.

Symbols that include "experimental_", "legacy_",
"private_", "temporary_", "deprecated_" as part
of their name (case-insensitive) are not
referenced by the on-line docs and don't need
comments.

Tables built for online only include public symbols.

- Better links for constructors, destructors, operators
- Fixed some minor public interfaces
- Removed _const crutch on operators
- Keep includes inside 100 columns

TBR=reed@google.com

Docs-Preview: https://skia.org/?cl=171900
Bug: skia:
Change-Id: I93b229c6625d800604671e05b82a14c06cb906d2
Reviewed-on: https://skia-review.googlesource.com/c/171900
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
2018-11-29 18:17:30 +00:00

7.4 KiB

SkPath Overview

Path contains Lines and Curves which can be stroked or filled. Contour is composed of a series of connected Lines and Curves. Path may contain zero, one, or more Contours. Each Line and Curve are described by Verb, Points, and optional Path_Conic_Weight.

Each pair of connected Lines and Curves share common Point; for instance, Path containing two connected Lines are described the Path_Verb sequence: SkPath::kMove_Verb, SkPath::kLine_Verb, SkPath::kLine_Verb; and a Point sequence with three entries, sharing the middle entry as the end of the first Line and the start of the second Line.

Path components Arc, Rect, Round_Rect, Circle, and Oval are composed of Lines and Curves with as many Verbs and Points required for an exact description. Once added to Path, these components may lose their identity; although Path can be inspected to determine if it describes a single Rect, Oval, Round_Rect, and so on.

Example

Path contains three Contours: Line, Circle, and Quad. Line is stroked but not filled. Circle is stroked and filled; Circle stroke forms a loop. Quad is stroked and filled, but since it is not closed, Quad does not stroke a loop.

Path contains a Path_Fill_Type which determines whether overlapping Contours form fills or holes. Path_Fill_Type also determines whether area inside or outside Lines and Curves is filled.

Example

Path is drawn filled, then stroked, then stroked and filled.

Path contents are never shared. Copying Path by value effectively creates a new Path independent of the original. Internally, the copy does not duplicate its contents until it is edited, to reduce memory use and improve performance.


Contour contains one or more Verbs, and as many Points as are required to satisfy Path_Verb_Array. First Path_Verb in Path is always SkPath::kMove_Verb; each SkPath::kMove_Verb that follows starts a new Contour.

Example

Each SkPath::moveTo starts a new Contour, and content after SkPath::close() also starts a new Contour. Since SkPath::conicTo is not preceded by SkPath::moveTo, the first Point of the third Contour starts at the last Point of the second Contour.

If final Path_Verb in Contour is SkPath::kClose_Verb, Line connects Path_Last_Point in Contour with first Point. A closed Contour, stroked, draws Paint_Stroke_Join at Path_Last_Point and first Point. Without SkPath::kClose_Verb as final Verb, Path_Last_Point and first Point are not connected; Contour remains open. An open Contour, stroked, draws Paint_Stroke_Cap at Path_Last_Point and first Point.

Example

Path is drawn stroked, with an open Contour and a closed Contour.


Contour length is distance traveled from first Point to Path_Last_Point, plus, if Contour is closed, distance from Path_Last_Point to first Point. Even if Contour length is zero, stroked Lines are drawn if Paint_Stroke_Cap makes them visible.

Example