| 1 | |
| 2 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 3 | |
| 4 | #include "gdkdihedralprivate.h"cxx . . $ `<file>/gdk/gdkdihedralprivate.h`/ |
| 5 | |
| 6 | /*< private > |
| 7 | * gdk_dihedral_get_mat2: |
| 8 | * transform: a dihedral |
| 9 | * @xx: return location for xx component |
| 10 | * @xy: return location for xy component |
| 11 | * @yx: return location for yx component |
| 12 | * @yy: return location for yy component |
| 13 | * |
| 14 | * Gets a 2x2 matrix representing the dihedral transform. |
| 15 | */ |
| 16 | void |
| 17 | gdk_dihedral_get_mat2cxx . . $ gdk_dihedral_get_mat2(28b0c0e89123d677). (GdkDihedralcxx . . $ GdkDihedral# transform, |
| 18 | float *xx, |
| 19 | float *xy, |
| 20 | float *yx, |
| 21 | float *yy) |
| 22 | { |
| 23 | const float mat[8][2][2] = { |
| 24 | [GDK_DIHEDRAL_NORMALcxx . . $ GDK_DIHEDRAL_NORMAL.] = { |
| 25 | { 1.0, 0.0 }, |
| 26 | { 0.0, 1.0 } |
| 27 | }, |
| 28 | [GDK_DIHEDRAL_90cxx . . $ GDK_DIHEDRAL_90.] = { |
| 29 | { 0.0, 1.0 }, |
| 30 | { -1.0, 0.0 } |
| 31 | }, |
| 32 | [GDK_DIHEDRAL_180cxx . . $ GDK_DIHEDRAL_180.] = { |
| 33 | { -1.0, 0.0 }, |
| 34 | { 0.0, -1.0 } |
| 35 | }, |
| 36 | [GDK_DIHEDRAL_270cxx . . $ GDK_DIHEDRAL_270.] = { |
| 37 | { 0.0, -1.0 }, |
| 38 | { 1.0, 0.0 } |
| 39 | }, |
| 40 | [GDK_DIHEDRAL_FLIPPEDcxx . . $ GDK_DIHEDRAL_FLIPPED.] = { |
| 41 | { -1.0, 0.0 }, |
| 42 | { 0.0, 1.0 } |
| 43 | }, |
| 44 | [GDK_DIHEDRAL_FLIPPED_90cxx . . $ GDK_DIHEDRAL_FLIPPED_90.] = { |
| 45 | { 0.0, 1.0 }, |
| 46 | { 1.0, 0.0 } |
| 47 | }, |
| 48 | [GDK_DIHEDRAL_FLIPPED_180cxx . . $ GDK_DIHEDRAL_FLIPPED_180.] = { |
| 49 | { 1.0, 0.0 }, |
| 50 | { 0.0, -1.0 } |
| 51 | }, |
| 52 | [GDK_DIHEDRAL_FLIPPED_270cxx . . $ GDK_DIHEDRAL_FLIPPED_270.] = { |
| 53 | { 0.0, -1.0 }, |
| 54 | { -1.0, 0.0 } |
| 55 | }, |
| 56 | }; |
| 57 | |
| 58 | *xx = mat[transform][0][0]; |
| 59 | *xy = mat[transform][1][0]; |
| 60 | *yx = mat[transform][0][1]; |
| 61 | *yy = mat[transform][1][1]; |
| 62 | } |
| 63 | |
| 64 | /*< private > |
| 65 | * gdk_dihedral_combine: |
| 66 | * @first: a dihedral transform |
| 67 | * @second: another dihedral transform |
| 68 | * |
| 69 | * Combines two dihedral transforms. |
| 70 | * |
| 71 | * Returns: the dihedral transform that applies @first, then @second |
| 72 | */ |
| 73 | GdkDihedralcxx . . $ GdkDihedral# |
| 74 | gdk_dihedral_combinecxx . . $ gdk_dihedral_combine(e07a874bc21d8d72). (GdkDihedralcxx . . $ GdkDihedral# first, |
| 75 | GdkDihedralcxx . . $ GdkDihedral# second) |
| 76 | { |
| 77 | return ((second & 4) ^ (first & 4)) | |
| 78 | ((((second & 3) * (((first & 4) >> 1) + 1)) + first) & 3); |
| 79 | } |
| 80 | |
| 81 | /*< private > |
| 82 | * gdk_dihedral_invert: |
| 83 | * @self: a dihedral transform |
| 84 | * |
| 85 | * Inverts a dihedral transform. |
| 86 | * |
| 87 | * Returns: the inverse of @self |
| 88 | */ |
| 89 | GdkDihedralcxx . . $ GdkDihedral# |
| 90 | gdk_dihedral_invertcxx . . $ gdk_dihedral_invert(2f3969c1a6d347ec). (GdkDihedralcxx . . $ GdkDihedral# self) |
| 91 | { |
| 92 | return ((4 - self) * (((self & 4) >> 1) + 1) & 3) | (self & 4); |
| 93 | } |
| 94 | |
| 95 | /*< private > |
| 96 | * gdk_dihedral_swaps_xy: |
| 97 | * @self: a dihedral transform |
| 98 | * |
| 99 | * Returns whether the transform exchanges width and height. |
| 100 | * |
| 101 | * Returns: true if the transform exchanges width and height |
| 102 | */ |
| 103 | gbooleancxx . . $ gboolean# |
| 104 | gdk_dihedral_swaps_xycxx . . $ gdk_dihedral_swaps_xy(eacf48c542704b98). (GdkDihedralcxx . . $ GdkDihedral# self) |
| 105 | { |
| 106 | return (self & 1) ? TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`! : FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 107 | } |
| 108 | |
| 109 | /*< private > |
| 110 | * gdk_dihedral_get_name: |
| 111 | * @self: a dihedral transform |
| 112 | * |
| 113 | * Returns a name for the transform. |
| 114 | * |
| 115 | * This is meant for debug messages. |
| 116 | * |
| 117 | * Returns: the name of the transform |
| 118 | */ |
| 119 | const char * |
| 120 | gdk_dihedral_get_namecxx . . $ gdk_dihedral_get_name(9a0110bd8f77a49f). (GdkDihedralcxx . . $ GdkDihedral# self) |
| 121 | { |
| 122 | const char *name[] = { |
| 123 | "normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180", "flipped-270" |
| 124 | }; |
| 125 | |
| 126 | return name[self]; |
| 127 | } |