Skip to content

Commit

Permalink
Add Path.stroke()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Aug 4, 2021
1 parent c7e2f3a commit ba013f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -166,6 +166,7 @@ Geometric primitives are all very well, but there is a limit to what you can cre
Builders create a 3D `Mesh` from a (typically) 2D `Path`. The following builders are defined as static constructor functions on the `Mesh` type:

- `fill` - This builder fills a single `Path` to create a pair of `Polygon`s (front and back faces).
- `stroke` - This builder strokes a single `Path` to create a line of quads.
- `lathe` - This builder takes a 2D `Path` and rotates it around the Y-axis to create a rotationally symmetrical `Mesh`. This is an easy way to create complex shapes like candlesticks, chess pieces, rocket ships, etc.
- `extrude` - This builder fills a `Path` and extrudes it along its axis, or another path. This can turn a circular path into a tube, or a square into a cube etc.
- `loft` - This builder is similar to `extrude`, but takes multiple `Path`s and joins them. The `Path`s do not need to be the same shape, but must all have the same number of points and subpaths. To work correctly, the `Path`s must be pre-positioned in 3D space so they do not all lie on the same plane.
Expand Down
18 changes: 17 additions & 1 deletion Sources/Shapes.swift
Expand Up @@ -858,7 +858,7 @@ public extension Mesh {
}
}

/// Fill a path to form a polygon
/// Fill a path to form one or more polygons
static func fill(
_ shape: Path,
faces: Faces = .default,
Expand Down Expand Up @@ -891,4 +891,20 @@ public extension Mesh {
)
}
}

/// Stroke a path with the specified line width, depth and material
static func stroke(
_ shape: Path,
width: Double = 0.01,
depth: Double = 0,
faces: Faces = .default,
material: Material? = nil
) -> Mesh {
extrude(
.rectangle(width: width, height: depth),
along: shape,
faces: faces,
material: material
)
}
}

0 comments on commit ba013f2

Please sign in to comment.