Skip to content

Add polygon drawing primitive - #314

Merged
laurmaedje merged 3 commits into
typst:mainfrom
ollelogdahl:polygon
Mar 28, 2023
Merged

laurmaedje merged 3 commits into
typst:mainfrom
ollelogdahl:polygon

Conversation

@ollelogdahl

@ollelogdahl ollelogdahl commented Mar 25, 2023 •

Copy link
Copy Markdown
Contributor

This patch adds a new polygon drawing primitive.

A polygon is a closed Path object, with fill and stroke capabilities. Compared to the other shapes, it is not a content container, as the points are variadic. A suggestion was made that polygons should be able to have content, but this one is strictly for drawing. I believe a patch can be made later to support content in it, if variadic+content ever becomes possible.

This is related to the discussion at: #260

@ollelogdahl ollelogdahl changed the title Implemented polygon drawing primitives Add polygon drawing primitive Mar 27, 2023
This patch adds a new polygon drawing primitive. Polygons
are implemented as closed-Path objects.

A polygon which doesn't have a single point, shouldn't crash.
One solution is to allow empty polygons, and just dont render
them.

Polygons are fully tested, including self-intersections and
antiparallelograms.
Comment thread library/src/visualize/polygon.rs Resolved
Comment thread library/src/visualize/polygon.rs Resolved
Comment thread library/src/visualize/polygon.rs Resolved
Comment thread library/src/visualize/polygon.rs Resolved
Comment thread library/src/visualize/polygon.rs Resolved
@ollelogdahl

ollelogdahl commented Mar 27, 2023 •

Copy link
Copy Markdown
Contributor Author

@laurmaedje I have revised my commit accordingly. I agree on all points. Hope it looks better now!

@ollelogdahl
ollelogdahl requested a review from laurmaedje March 28, 2023 13:22
@laurmaedje
laurmaedje merged commit 44165d0 into typst:main Mar 28, 2023
@laurmaedje

Copy link
Copy Markdown
Member

Thanks!

@ollelogdahl
ollelogdahl deleted the polygon branch March 28, 2023 15:09
nikabyn pushed a commit to nikabyn/typst that referenced this pull request Mar 29, 2023
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants