Matthias Clasen
cd6d88fca5
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 would 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.
2023-07-06 13:08:05 -04:00
Matthias Clasen
14411b0428
contour: Special-case circles for strokes
...
The outline of a circle is just two circles.
2023-07-06 13:08:05 -04:00
Matthias Clasen
afdb001a4b
contour: Special-case rectangles for strokes
...
In many cases, the outline of a rectangle is just
two rectangles.
2023-07-06 13:08:05 -04:00
Matthias Clasen
3965ee59cd
API: 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.
2023-07-06 13:08:05 -04:00
Matthias Clasen
be94463521
API: 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.
2023-07-06 13:08:05 -04:00
Matthias Clasen
e6e2caef6f
API: Add GSK_LINE_JOIN_ARCS
...
This is from SVG 2.
2023-07-06 13:08:05 -04:00
Matthias Clasen
491ace9046
API: Add gsk_path_measure_get_curvature
...
We have this information available, and it can
be used for some neat demos, so add an api for it.
2023-07-06 13:08:05 -04:00
Matthias Clasen
b9f192caa5
Add a test for gsk_curve_offset
...
The stroker relies on offsetting.
This only tests a few very simple cases.
2023-07-06 13:08:05 -04:00
Matthias Clasen
bec7dbcf91
curve: 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.
2023-07-06 13:08:05 -04:00
Matthias Clasen
e7590e78ac
Add a test for tangents of degenerate curves
...
The stroker relies on these to work.
2023-07-06 13:02:19 -04:00
Matthias Clasen
44bccbcf70
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.
2023-07-06 13:02:19 -04:00
Matthias Clasen
e13cbd9af3
Add a performance test for curve eval
...
All curve types are equally fast here.
2023-07-06 13:02:19 -04:00
Matthias Clasen
29631b6832
Add a performance test for curve intersection
...
This shows how much more expensive curve
intersections are.
2023-07-06 13:02:19 -04:00
Matthias Clasen
1c20a3153c
Add curve split tests
2023-07-06 13:02:19 -04:00
Matthias Clasen
455a44513c
Add special-case curve tests
2023-07-06 13:02:19 -04:00
Matthias Clasen
bb4f406f3b
Add curve match tests
...
Add tests that check that the curve api agrees on
values for a quadratic and its equivalent cubic
and conic curves.
2023-07-06 13:02:19 -04:00
Matthias Clasen
61472ac050
Add curve intersection and bounds tests
...
These tests check that gsk_curve_intersect finds
the intersections we want and get_bounds returns
propert bounding boxes.
2023-07-06 13:02:19 -04:00
Matthias Clasen
2889d58d56
curve: Add gsk_curve_intersect
...
Add a way to find the intersections of two curves.
We can handle some curve-line intersections directly,
the general case is handled via bisecting.
This will be used in stroking and path ops.
2023-07-06 13:02:19 -04:00
Matthias Clasen
b58c60a1ef
curve: Add gsk_curve_print
...
Useful for debugging.
2023-07-06 13:02:19 -04:00
Matthias Clasen
98f0e57d14
curve: Add gsk_curve_get_curvature
...
This will be used in the stroker.
2023-07-06 13:02:19 -04:00
Matthias Clasen
73a06b6b2a
curve: Add gsk_curve_get_normal
...
Its easy but thats no reason not to have this api.
2023-07-06 13:02:19 -04:00
Matthias Clasen
8258550df9
curve: Add gsk_curve_get_bounds
...
Add getters for bounding boxes of curves.
Bounding boxes are needed to implement intersection
via bisecting.
2023-07-06 13:02:19 -04:00
Matthias Clasen
6305725523
curve: Add some curve utilities
...
Internal apis:
- gsk_curve_get_curvature_points
- gsk_curve_get_cusps
These apis will be used in the stroker
and in path ops.
2023-07-06 13:02:19 -04:00
Matthias Clasen
78f70a5720
Add a bounding box type
...
graphene_rect_t does not quite work for this purpose.
2023-07-06 13:02:19 -04:00
Matthias Clasen
02402b2881
tools: Add gtk4-path-tool
...
This comes in handy for testing, among other things.
For now, this supports decomposing, transforming,
reversing, restricting, rendering and preview.
2023-07-06 13:00:21 -04:00
Matthias Clasen
71d03be38c
Add decomposition tests
...
We don't have good error bounds for conics,
unfortunately. But we can test that we decompose
into the right curves.
2023-07-06 13:00:21 -04:00
Matthias Clasen
be6238096b
path: Allow limiting curve types in foreach
...
This is useful if your rendering system can't
handle certain kinds of curves, such as conics.
2023-07-06 13:00:21 -04:00
Matthias Clasen
27a2e97852
curve: 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.
But it also allows for other use cases, such as
raising the degree of quadratics to cubics.
An auxiliary API introduced here is gsk_curve_elevate.
2023-07-06 13:00:21 -04:00
Matthias Clasen
f848f44613
API: Add gsk_path_transform
...
This is an obvious operation to want for paths.
2023-07-06 13:00:20 -04:00
Matthias Clasen
59585d2de4
API: Add gsk_path_reverse
...
This is a natural operation, and useful for debugging things.
2023-07-06 13:00:20 -04:00
Matthias Clasen
09b5564fa8
Add a test for gsk_curve_reverse
...
The stroker relies on this working.
2023-07-06 13:00:20 -04:00
Matthias Clasen
54828e0a74
curve: Add gsk_curve_reverse
...
This is a useful operation that will be used,
among other places, in stroking.
2023-07-06 13:00:20 -04:00
Matthias Clasen
60e78cb210
Update affected tests
...
We preserve quadratics in the SVG path roundtrip
tests now.
2023-07-06 12:56:47 -04:00
Matthias Clasen
ee0414f243
Add quadratic curves
...
API-wise, this adds
- GSK_PATH_QUAD
- GSK_PATH_FOREACH_ALLOW_QUAD
- gsk_path_builder_quad_to and _rel_quad_to
2023-07-06 12:56:47 -04:00
Matthias Clasen
f813bd808b
Rename curve to cubic
...
This is to make room in the api for quadratic curves.
In detail:
- Replace GSK_PATH_CURVE by _CUBIC
- Rename gsk_path_builder_curve_to to _cubic_to
- Replace GSK_PATH_FOREACH_ALLOW_CURVE with _CUBIC
- Replace GskCurveCurve with GskCubicCurve
2023-07-06 12:56:45 -04:00
Matthias Clasen
40d0c1d73f
gsk_path_measure_is_closed -> gsk_path_is_closed
...
This is a property of the path that doesn't need
a measure to determine, so move the API to GskPath.
2023-07-06 12:55:09 -04:00
Matthias Clasen
b4cd601baa
contour: Handle reverse circle segments
...
If we can't append a circle contour, just
convert to a standard contour. This warning
was occasionally causing tests to fail
(when a suitable random path gets generated).
2023-07-06 12:54:47 -04:00
Matthias Clasen
6428b6654d
Clean up fill and stroke node apis
...
We were missing consts in a few places.
2023-07-06 12:54:47 -04:00
Matthias Clasen
06503f9604
gsk: Use stroke bounds for the stroke node
...
We have the right api to use.
2023-07-06 12:54:47 -04:00
Matthias Clasen
4b0313c1cd
Private header cleanup
...
These includes break using the private headers
in internal tests, so fix them up to work for
that case.
2023-07-06 12:54:47 -04:00
Matthias Clasen
32a934ecaa
path_text demo: Fixup
...
We don't want any filtering by curve type here.
2023-07-06 12:54:47 -04:00
Matthias Clasen
69d1826a6d
pathmeasure: Drop first/last
...
We no longer restrict measures, so n_contours
is sufficient.
2023-07-06 12:54:10 -04:00
Matthias Clasen
1fac0f5391
pathmeasure: Drop some unused apis
...
We are not convinced that it is a good idea
to expose the concept of contours, and these
apis are entirely unused, so drop them.
2023-07-06 12:50:30 -04:00
Matthias Clasen
ae085c3ae9
curve: Explicitly initialize memory
...
Unitialized memory warnings aren't fun.
2023-07-06 12:50:30 -04:00
Matthias Clasen
47c471cffa
Be less demanding in the get_point test
...
When looking for discontinuities, there
is no need to check for epsilons. As we
move close to the end of one contour / the
beginning of the next, the path length distance
between the two points will get arbitrarily
small, so we can just check that the distance
between the points is more than twice that.
This makes spurious failures of the /path/get_point
test go away.
2023-07-06 12:50:30 -04:00
Matthias Clasen
08d6e24370
Plug a memory leak in the path tests
2023-07-06 12:50:30 -04:00
Matthias Clasen
3d65c0da84
Only test conic weights between 1/20 and 20
...
The rest just give us no end of numeric trouble.
2023-07-06 12:50:30 -04:00
Matthias Clasen
d5ab5336aa
pathbuilder: Avoid trouble with sincos
...
The Windows builds seem to have problem with
this handling of sincos(), so do it the same
way we do it elsewere, by defining _sincos().
2023-07-06 12:50:30 -04:00
Matthias Clasen
726ebecc82
Make gsk_stroke_to_cairo public
...
It comes in handy, and does no harm.
2023-07-06 12:50:30 -04:00
Matthias Clasen
e6ba20951b
Add comment for conic curves
2023-07-06 12:50:30 -04:00