Commit Graph

68043 Commits

Author SHA1 Message Date
Matthias Clasen
be7fead1fb Add gsk_path_offset
Add a function that takes a path, and offsets it
by some distance, applying line-join parameters
as needed.

This commit just adds the api, the implementation
will be in the following commit.
2020-12-27 00:10:08 -05:00
Matthias Clasen
b871c2a3cb stroker: Cleanups
Move some utility functions around.
2020-12-26 23:57:41 -05:00
Matthias Clasen
7c67a9c76a stroker: Implement arcs
Implement arced joins as specified in SVG2.
2020-12-26 23:57:41 -05:00
Matthias Clasen
427e185bcf Add GSK_LINE_JOIN_ARCS
Implementation will follow.
2020-12-26 23:57:41 -05:00
Matthias Clasen
30552e9988 xxx: assorted fixes for special contours
Fix winding numbers, and strokes wrt to direction.
2020-12-26 23:57:41 -05:00
Matthias Clasen
08d8d6c029 Add another stroker test
Check that the outlines of random paths look as
expected. We currently have to exclude paths where
points get too close to each other.
2020-12-26 23:57:41 -05:00
Matthias Clasen
61a84956d4 Add basic tests for strokes
Add tests to check that any point on a path is
always at most half the line-width away from the
stroke path with that line-width.
2020-12-26 23:57:41 -05:00
Matthias Clasen
e44780923a Implement stroking
Implement gsk_contour_default_add_stroke, which takes a contour
and stroke parameters, and adds contours to a path builder for
the outline that woul be produced by stroking the path with these
parameters.

The current implementation does not try to handle short segments
in the vicinity of sharp joins in any special way, so there can
be some artifacts in that situation.
2020-12-26 23:57:41 -05:00
Matthias Clasen
dd1a2e0396 Special-case circles for strokes
The outline of a circle is just two circles.
2020-12-26 23:57:41 -05:00
Matthias Clasen
0100c33b71 Special-case rects for strokes
In many cases, the outline of a rectangle is just
two rectangles.
2020-12-26 23:57:41 -05:00
Matthias Clasen
8b8197a662 Add gsk_path_stroke
Add the plumbing that will let us do special-case stroking
for rectangles, circles and other special contours. There
is no implementation yet.
2020-12-26 23:57:41 -05:00
Matthias Clasen
e293f10fa1 Add gsk_curve_get_curvature
This will be used in the stroker.
2020-12-26 23:56:26 -05:00
Matthias Clasen
3a4c3c3d8c Add gsk_curve_get_normal
Its easy but thats no reason not to have this api.
2020-12-26 23:56:26 -05:00
Matthias Clasen
944735071e Add a test for gsk_curve_offset
The stroker relies on offsetting.
This only tests a few very simple cases.
2020-12-26 23:56:26 -05:00
Matthias Clasen
91356de96a Add a test for gsk_curve_reverse
The stroker relies on this working.
2020-12-26 23:56:26 -05:00
Matthias Clasen
3f29c50800 Add a test for tangents of degenerate curves
The stroker relies on these to work.
2020-12-26 23:56:26 -05:00
Matthias Clasen
59b1f9e7b1 curve: Handle degenerate cases
Nothing prevents control points from being identical,
and if that happens, some of our constructions involving
tangents and normals break down. Handle these cases in
get_{start,end}_tangent and offset, for the case of
cubics.
2020-12-26 23:56:26 -05:00
Matthias Clasen
dd3cf83a35 Add gsk_curve_reverse
This will be used in stroking.
2020-12-26 23:56:26 -05:00
Matthias Clasen
7f8a9e5543 Add gsk_curve_offset
This method creates an offset curve from an existing
curve by just moving the control points laterally.

This will be used in stroking.
2020-12-26 23:56:26 -05:00
Matthias Clasen
8523c6cb2d Add conic decomposition tests
We don't have good error bounds here, unfortunately.
2020-12-26 23:56:26 -05:00
Matthias Clasen
49b25424c5 path: support conic->curve in foreach 2020-12-26 23:56:26 -05:00
Matthias Clasen
db2046cb67 Add gsk_curve_decompose_curve
This is mainly useful for decomposing a conic into
cubics. The criterion here for terminating the
subdivision is very improvised.
2020-12-26 23:56:26 -05:00
Matthias Clasen
61264165ff Add a performance test for curve eval
All curve types are equally fast here.
2020-12-26 23:56:26 -05:00
Matthias Clasen
7b3d283fc0 Add a performance test for curve intersection
This shows how much more expensive curve
intersections are.
2020-12-26 23:56:26 -05:00
Matthias Clasen
44ffed0283 Add curve split tests 2020-12-26 23:56:26 -05:00
Matthias Clasen
e91ec1f26f Add another intersection testcase
This tests horizontal line/conic intersection,
which failed before the fix in the previous commit.
2020-12-26 23:56:26 -05:00
Matthias Clasen
eace55daa6 xxx: work around bounding box problems
graphene_rect_intersect returns FALSE when you
intersect the bounding boxes of axis-aligned
lines, so we never find intersections with those.

Make things better by making the bounding boxes worse.
2020-12-26 23:56:26 -05:00
Matthias Clasen
097e58558b Add curve intersection tests
These tests check that gsk_curve_intersect finds
the intersections we want.
2020-12-26 23:56:26 -05:00
Matthias Clasen
f0acb0f073 Add gsk_curve_intersect
Add a way to find the intersections of two curves.
This will be used in stroking.
2020-12-26 23:56:25 -05:00
Matthias Clasen
b779ba19ca Add gsk_curve_get_bounds
Add getters for bounding boxes of curves.
2020-12-26 23:56:25 -05:00
Matthias Clasen
aa0f1ce956 Only test conic weights between 1/20 and 20
The rest just give us no end of numeric trouble.
2020-12-26 23:56:25 -05:00
Benjamin Otte
e9d01c1a63 Ottie: Add ottie-editor 2020-12-27 01:12:11 +01:00
Benjamin Otte
e235392894 ottie: Add a snapshot testsuite test
The test takes a lottie file and a timestamp in seconds and produces a
rendernode at that timestamp.

It then serializes that node and compares it via diff(1) with a file
containing the expected output.

This is a lot stricter than it needs to be (because different node files
can generate the same output and updates to the rendering pipeline can
break everything) but I chose this method on purpose because it does a
good job at guarding against accidental changes in other parts of the
code.

It's also better than comparing image output because it avoids
antialiasing artifacts when using curves and things like that.
2020-12-27 01:12:11 +01:00
Benjamin Otte
73904f3034 ottie: Add a command-line tool
Supports:

 * Taking a screenie:
   ottie image file.lottie image.png

 * Recording a rendernode:
   ottie node file.lottie render.node

 * Encoding an image:
   ottie video file.lottie video.webm
2020-12-27 01:12:11 +01:00
Benjamin Otte
c2ed71af7a Ottie: Add 2020-12-27 01:12:11 +01:00
Benjamin Otte
aa2f6345c8 path: Add gsk_path_builder_add_ellipse() 2020-12-27 00:31:18 +01:00
Benjamin Otte
cef1bc9098 path: Change semantics of gtk_path_builder_add_segment()
Allow start >= end to mean that the path continues at the beginning
after reaching the end until it reaches the point at @end.
2020-12-27 00:31:18 +01:00
Benjamin Otte
828ccc51d9 path: Add gsk_path_measure_is_closed () 2020-12-27 00:31:18 +01:00
Benjamin Otte
8397d10c20 path: Add gsk_path_measure_restrict_to_contour() 2020-12-27 00:31:18 +01:00
Matthias Clasen
78d06e58d0 Add gsk_path_measure_get_{path,tolerance}
These are just nice apis to have and avoid having to carry
these around as extra arguments in many places.

This was showing up as inconvenience in writing tests
for the measure apis.
2020-12-27 00:31:18 +01:00
Benjamin Otte
a5e13cc96b xxx path)_fill 2020-12-27 00:31:18 +01:00
Matthias Clasen
776dc54c8a Add gsk_path_get_stroke_bounds
A relatively cheap way to get bounds for the area
that would be affected by stroking a path.
2020-12-27 00:31:18 +01:00
Benjamin Otte
ee6879fba8 testsuite: Add tests for the dasher 2020-12-27 00:31:18 +01:00
Benjamin Otte
14f9395476 path: Add a foreach function that dashes a path 2020-12-27 00:31:18 +01:00
Benjamin Otte
1349cf2454 path: Deal with non-uniformness of progress parameter
The progress is non-uniform, so simple translation of progress doesn't work.
So check if larger and smaller values inch closer towards minimal distance.
2020-12-27 00:31:18 +01:00
Benjamin Otte
d47ebd388c path: Always decompose conics into at least 2 segments
Conics are evil in that their parameter skews towards the center, and if
it's a very flat conic (weight almost equal to 0), then we'd approximate
it with a single segment and not subdivide, which would cause the
parameter to be wildly off around 0.25 or 0.75.

And that would cause offset calculations to fail.
2020-12-27 00:31:18 +01:00
Matthias Clasen
61214221b3 testsuite Add curve tangent tests 2020-12-27 00:31:18 +01:00
Benjamin Otte
7eb4ed8f86 testsuite: Add a test for the conic that got us segment() 2020-12-27 00:31:18 +01:00
Benjamin Otte
92b472fec1 path: Add gsk_curve_segment()
Using split() twice with scaled t values does not work with conics.
2020-12-27 00:31:18 +01:00
Benjamin Otte
7a6b008479 testsuite: Add a test for gsk_curve_decompose() 2020-12-27 00:31:18 +01:00