diff --git a/src/draw/shapes.typ b/src/draw/shapes.typ index 057573bd..d214c8ad 100644 --- a/src/draw/shapes.typ +++ b/src/draw/shapes.typ @@ -1069,10 +1069,10 @@ let (rx, ry) = radius if rx > 0 or ry > 0 { let m = 0.551784 - let p0 = (p0.at(0) * m * radius.at(0), - p0.at(1) * m * radius.at(1)) - let p1 = (p1.at(0) * m * radius.at(0), - p1.at(1) * m * radius.at(1)) + let p0 = (p0.at(0) * m * rx, + p0.at(1) * m * ry) + let p1 = (p1.at(0) * m * rx, + p1.at(1) * m * ry) (path-util.cubic-segment(s, e, vector.add(s, p0), vector.add(e, p1)),) @@ -1098,14 +1098,14 @@ let (p6, p7) = get-corner-pts(sw, (x1, y1, z), ( 1, 0), ( 0, 1)) let segments = () - segments += corner-arc(nw, p0, p1, (0, 1), (-1, 0)) - if p1 != p2 { segments += (path-util.line-segment((p1, p2)),) } - segments += corner-arc(ne, p2, p3, (1, 0), (0, 1)) - if p3 != p4 { segments += (path-util.line-segment((p3, p4)),) } - segments += corner-arc(se, p4, p5, (0, -1), (1, 0)) - if p5 != p6 { segments += (path-util.line-segment((p5, p6)),) } - segments += corner-arc(sw, p6, p7, (-1, 0), (0,-1)) - if p7 != p0 { segments += (path-util.line-segment((p7, p0)),) } + segments += corner-arc(nw, p1, p0, (-1,0), (0, 1)) + if p0 != p7 { segments += (path-util.line-segment((p0, p7)),) } + segments += corner-arc(sw, p7, p6, (0,-1), (-1,0)) + if p6 != p5 { segments += (path-util.line-segment((p6, p5)),) } + segments += corner-arc(se, p5, p4, (1, 0), (0,-1)) + if p4 != p3 { segments += (path-util.line-segment((p4, p3)),) } + segments += corner-arc(ne, p3, p2, (0, 1), (1, 0)) + if p2 != p1 { segments += (path-util.line-segment((p2, p1)),) } drawable.path(segments, fill: style.fill, stroke: style.stroke, close: true) } diff --git a/src/drawable.typ b/src/drawable.typ index 2c3a5de4..4e74c8a6 100644 --- a/src/drawable.typ +++ b/src/drawable.typ @@ -81,23 +81,28 @@ ( path-util.cubic-segment( (x, top, z), - (right, y, z), - (x + m * rx, top, z), - (right, y + m * ry, z), + (left, y, z), + (x - m * rx, top, z), + (left, y + m * ry, z), ), path-util.cubic-segment( - (right, y, z), + (left, y, z), (x, bottom, z), - (right, y - m * ry, z), - (x + m * rx, bottom, z), + (left, y - m * ry, z), + (x - m * rx, bottom, z), ), path-util.cubic-segment( (x, bottom, z), - (left, y, z), - (x - m * rx, bottom, z), - (left, y - m * ry, z), + (right, y, z), + (x + m * rx, bottom, z), + (right, y - m * ry, z), + ), + path-util.cubic-segment( + (right, y, z), + (x, top, z), + (right, y + m * ry, z), + (x + m * rx, top, z) ), - path-util.cubic-segment((left, y, z), (x, top, z), (left, y + m * ry, z), (x - m * rx, top, z)), ), stroke: stroke, fill: fill, diff --git a/tests/projection/ortho/ref/1.png b/tests/projection/ortho/ref/1.png index 5aa547da..cf7de379 100644 Binary files a/tests/projection/ortho/ref/1.png and b/tests/projection/ortho/ref/1.png differ diff --git a/tests/projection/ortho/test.typ b/tests/projection/ortho/test.typ index d55fc110..a5949f8e 100644 --- a/tests/projection/ortho/test.typ +++ b/tests/projection/ortho/test.typ @@ -118,3 +118,32 @@ line((-1,-1), (1,-1), (0,1), close: true) }) }) + +// Face order of library shapes +#test-case({ + import draw: * + ortho(cull-face: "cw", { + rect((-1, -1), (1, 1), radius: .5) + }) +}) + +#test-case({ + import draw: * + ortho(cull-face: "cw", { + circle((0,0)) + }) +}) + +#test-case({ + import draw: * + ortho(cull-face: "cw", { + arc((0,0), start: 0deg, stop: 270deg, mode: "PIE") + }) +}) + +#test-case({ + import draw: * + ortho(cull-face: "cw", { + content((0,0), [Text]) + }) +})