Skip to content

Commit

Permalink
PR Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Aug 11, 2024
1 parent 437c04e commit 30dc5d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/draw/projection.typ
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
(0, 0, 0, 1),
)

// Sort drawables by median or max segment z-value
#let _sort-by-distance(drawables) = {
return drawables.sorted(key: d => {
let z = none
Expand Down Expand Up @@ -54,7 +53,7 @@
// - projection-matrix (matrix): Projection matrix
// - reset-transform (bool): Ignore the current transformation matrix
// - sorted (bool): Sort drawables by maximum distance (front to back)
// - cull-face (none,string): Enable back-face culling if set to `"cw"` for clockwise
// - cull-face (none,str): Enable back-face culling if set to `"cw"` for clockwise
// or `"ccw"` for counter-clockwise. Polygons of the specified order will not get drawn.
#let _projection(body, view-matrix, projection-matrix, reset-transform: true, sorted: true, cull-face: "cw") = {
(ctx => {
Expand Down Expand Up @@ -122,7 +121,7 @@
/// - y (angle): Y-axis rotation angle
/// - z (angle): Z-axis rotation angle
/// - sorted (bool): Sort drawables by maximum distance (front to back)
/// - cull-face (none,string): Enable back-face culling if set to `"cw"` for clockwise
/// - cull-face (none,str): Enable back-face culling if set to `"cw"` for clockwise
/// or `"ccw"` for counter-clockwise. Polygons of the specified order will not get drawn.
/// - reset-transform (bool): Ignore the current transformation matrix
/// - body (element): Elements to draw
Expand Down
16 changes: 9 additions & 7 deletions src/polygon.typ
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
///
/// Cubic segments get linearized by sampling.
///
/// - segment (list): List of segments
/// - segment (array): List of segments
/// - samples (int): Number of samples
/// -> List of vectors
/// -> array
#let from-segments(segments, samples: 10) = {
import "/src/bezier.typ": cubic-point
let poly = ()
Expand All @@ -24,10 +24,10 @@
/// Computes the signed area of a 2D polygon.
///
/// The formula used is the following:
/// $ 1/2 sum_i=0^n-1 x_i*y_i+1 - x_i+1*y_i $
/// $ 1/2 \sum_{i}=0^{n-1} x_i*y_i+1 - x_i+1*y_i $
///
/// - points (list): List of Vectors of dimension >= 2
/// -> Signed area
/// - points (array): List of Vectors of dimension >= 2
/// -> float
#let signed-area(points) = {
let a = 0
let n = points.len()
Expand All @@ -45,8 +45,10 @@
/// Returns the winding order of a 2D polygon
/// by using it's signed area.
///
/// - point (list): List of polygon points
/// -> "ccw" (counter clock-wise) or "cw" (clock-wise) or none
/// Returns either "ccw" (counter clock-wise) or "cw" (clock-wise) or none.
///
/// - point (array): List of polygon points
/// -> str,none
#let winding-order(points) = {
let area = signed-area(points)
if area > 0 {
Expand Down

0 comments on commit 30dc5d8

Please sign in to comment.