mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-24 12:41:16 +00:00
Add gdk_dihedral_swaps_xy
This function determines if a dihedral transform swaps x and y.
This commit is contained in:
parent
61c22d1c72
commit
6065165060
@ -65,3 +65,8 @@ gdk_dihedral_invert (GdkDihedral self)
|
||||
return ((4 - self) * (((self & 4) >> 1) + 1) & 3) | (self & 4);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_dihedral_swaps_xy (GdkDihedral self)
|
||||
{
|
||||
return (self & 1) ? TRUE : FALSE;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ void gdk_dihedral_get_mat2 (GdkDihedral
|
||||
GdkDihedral gdk_dihedral_combine (GdkDihedral first,
|
||||
GdkDihedral second);
|
||||
GdkDihedral gdk_dihedral_invert (GdkDihedral self);
|
||||
gboolean gdk_dihedral_swaps_xy (GdkDihedral self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -331,7 +331,7 @@ gsk_rounded_rect_dihedral (GskRoundedRect *dest,
|
||||
|
||||
gsk_rect_dihedral (&src->bounds, dihedral, &dest->bounds);
|
||||
|
||||
if (dihedral & 1)
|
||||
if (gdk_dihedral_swaps_xy (dihedral))
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
|
@ -64,12 +64,26 @@ test_inversions (void)
|
||||
g_assert_cmpint (gdk_dihedral_invert (GDK_DIHEDRAL_FLIPPED_270), ==, GDK_DIHEDRAL_FLIPPED_270);
|
||||
}
|
||||
|
||||
static void
|
||||
test_swaps (void)
|
||||
{
|
||||
g_assert_false (gdk_dihedral_swaps_xy (GDK_DIHEDRAL_NORMAL));
|
||||
g_assert_true (gdk_dihedral_swaps_xy (GDK_DIHEDRAL_90));
|
||||
g_assert_false (gdk_dihedral_swaps_xy (GDK_DIHEDRAL_180));
|
||||
g_assert_true (gdk_dihedral_swaps_xy (GDK_DIHEDRAL_270));
|
||||
g_assert_false (gdk_dihedral_swaps_xy (GDK_DIHEDRAL_FLIPPED));
|
||||
g_assert_true (gdk_dihedral_swaps_xy (GDK_DIHEDRAL_FLIPPED_90));
|
||||
g_assert_false (gdk_dihedral_swaps_xy (GDK_DIHEDRAL_FLIPPED_180));
|
||||
g_assert_true (gdk_dihedral_swaps_xy (GDK_DIHEDRAL_FLIPPED_270));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/dihedral/inversions", test_inversions);
|
||||
g_test_add_func ("/dihedral/swaps", test_swaps);
|
||||
g_test_add_func ("/dihedral/combinations", test_combinations);
|
||||
g_test_add_func ("/dihedral/invariants", test_invariants);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user