Crates.io | beziercurve-wkt |
lib.rs | beziercurve-wkt |
version | 0.1.3 |
source | src |
created_at | 2020-04-16 17:22:10.113053 |
updated_at | 2021-10-24 07:47:48.582036 |
description | Serialize / deserialize bezier curves to / from a WKT-like string + do clipping operations |
homepage | https://github.com/fschutt/beziercurve-wkt |
repository | https://github.com/fschutt/beziercurve-wkt |
max_upload_size | |
id | 230843 |
size | 83,811 |
This libary exists because PostGis (current version 12.0) does not support Bezier curves. However, keeping data in tables is still very useful. It's also sometimes necessary to have a human-readable format of Bezier curves. So instead of keeping the data in a binary format, the data is kept in string format and this libary provides a serializer / deserializer for it.
The string format for Bezier curves looks like this:
BEZIERCURVE((0.0 1.0, 2.0 1.0), (2.0 1.0, 46.0 20.0, 0.0 0.0), (0.0 0.0, 40.0, 47.0, 50.0 30.0, 2.0 1.0))
The parser looks at the points and determines the type of point by its length:
(x1 y1, x2 y2) -> Line from p1 to p2
(x1 y1, x2 y2, x3 y3) -> Quadratic bezier curve from p1 to p3 with control point p2
(x1 y1, x2 y2, x3 y3, x4 y4) -> Cubic bezier curve from p1 to p4 with control points p2 and p3
The reason for duplicating the point on each "item" / section is so that the BezierCurve can be constructed in parallel, if necessary.
Additional to serialization / deserialization, this library features tools to:
MIT
License: MIT