diff --git a/docs/reference/gsk/gsk4.toml.in b/docs/reference/gsk/gsk4.toml.in index e451183ba8..813f974c4c 100644 --- a/docs/reference/gsk/gsk4.toml.in +++ b/docs/reference/gsk/gsk4.toml.in @@ -36,6 +36,8 @@ content_images = [ "gtk-logo.svg", "images/caps-dark.png", "images/caps-light.png", + "images/directions-dark.png", + "images/directions-light.png", "images/join-dark.png", "images/join-light.png", "images/path-dark.png", diff --git a/docs/reference/gsk/images/directions-dark.png b/docs/reference/gsk/images/directions-dark.png new file mode 100644 index 0000000000..77505ee462 Binary files /dev/null and b/docs/reference/gsk/images/directions-dark.png differ diff --git a/docs/reference/gsk/images/directions-light.png b/docs/reference/gsk/images/directions-light.png new file mode 100644 index 0000000000..c61840a84f Binary files /dev/null and b/docs/reference/gsk/images/directions-light.png differ diff --git a/docs/reference/gsk/images/directions.svg b/docs/reference/gsk/images/directions.svg new file mode 100644 index 0000000000..bb432a059e --- /dev/null +++ b/docs/reference/gsk/images/directions.svg @@ -0,0 +1,327 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GSK_PATH_FROM_START + GSK_PATH_FROM_START + GSK_PATH_TO_START + GSK_PATH_TO_START + GSK_PATH_TO_END + GSK_PATH_TO_END + GSK_PATH_FROM_END + GSK_PATH_FROM_END + + + + diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c index f708e242f6..d76327847a 100644 --- a/gsk/gskcontour.c +++ b/gsk/gskcontour.c @@ -509,7 +509,8 @@ gsk_standard_contour_get_tangent (const GskContour *contour, idx = point->idx; t = point->t; - if (t == 0 && direction == GSK_PATH_START) + if (t == 0 && (direction == GSK_PATH_FROM_START || + direction == GSK_PATH_TO_START)) { /* Look at the previous segment */ if (idx > 1) @@ -523,7 +524,8 @@ gsk_standard_contour_get_tangent (const GskContour *contour, t = 1; } } - else if (t == 1 && direction == GSK_PATH_END) + else if (t == 1 && (direction == GSK_PATH_TO_END || + direction == GSK_PATH_FROM_END)) { /* Look at the next segment */ if (idx < self->n_ops - 1) @@ -540,6 +542,9 @@ gsk_standard_contour_get_tangent (const GskContour *contour, gsk_curve_init (&curve, self->ops[idx]); gsk_curve_get_tangent (&curve, t, tangent); + + if (direction == GSK_PATH_TO_START || direction == GSK_PATH_FROM_END) + graphene_vec2_negate (tangent, tangent); } static float diff --git a/gsk/gskenums.h b/gsk/gskenums.h index 9ed0ee077e..fe157ab80b 100644 --- a/gsk/gskenums.h +++ b/gsk/gskenums.h @@ -292,17 +292,30 @@ typedef enum { /** * GskPathDirection: - * @GSK_PATH_START: The side that leads to the start of the path - * @GSK_PATH_END: The side that leads to the end of the path + * @GSK_PATH_FROM_START: The tangent in path direction of the incoming side + * of the path + * @GSK_PATH_TO_START: The tangent against path direction of the incoming side + * of the path + * @GSK_PATH_TO_END: The tangent in path direction of the outgoing side + * of the path + * @GSK_PATH_FROM_END: The tangent against path direction of the outgoing + * side of the path * * The values of the `GskPathDirection` enum are used to pick one - * of the two sides of the path that at a given point on the path. + * of the four tangents at a given point on the path. + * + * + * + * Path Tangents + * * * Since: 4.14 */ typedef enum { - GSK_PATH_START, - GSK_PATH_END + GSK_PATH_FROM_START, + GSK_PATH_TO_START, + GSK_PATH_TO_END, + GSK_PATH_FROM_END, } GskPathDirection; /** diff --git a/testsuite/gsk/path-special-cases.c b/testsuite/gsk/path-special-cases.c index bc83ba9249..927bc578d7 100644 --- a/testsuite/gsk/path-special-cases.c +++ b/testsuite/gsk/path-special-cases.c @@ -466,8 +466,8 @@ test_path_point (void) g_assert_true (rp->t == 1); gsk_path_point_get_position (&point, path, &pos); - gsk_path_point_get_tangent (&point, path, GSK_PATH_START, &t1); - gsk_path_point_get_tangent (&point, path, GSK_PATH_END, &t2); + gsk_path_point_get_tangent (&point, path, GSK_PATH_TO_START, &t1); + gsk_path_point_get_tangent (&point, path, GSK_PATH_TO_END, &t2); curvature = gsk_path_point_get_curvature (&point, path, ¢er); g_assert_true (graphene_point_equal (&pos, &GRAPHENE_POINT_INIT (100, 100)));