From 30dc5d80e7ccbc57e8e7ba7826830da90d904615 Mon Sep 17 00:00:00 2001 From: Johannes Wolf Date: Mon, 12 Aug 2024 00:07:22 +0200 Subject: [PATCH] PR Fixes --- src/draw/projection.typ | 5 ++--- src/polygon.typ | 16 +++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/draw/projection.typ b/src/draw/projection.typ index 63db7f96..68b22774 100644 --- a/src/draw/projection.typ +++ b/src/draw/projection.typ @@ -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 @@ -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 => { @@ -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 diff --git a/src/polygon.typ b/src/polygon.typ index 99955f67..563d6c22 100644 --- a/src/polygon.typ +++ b/src/polygon.typ @@ -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 = () @@ -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() @@ -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 {