1// Package pango was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package pango
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gobject/types"
12)
13
14// A `PangoMatrix` specifies a transformation between user-space
15// and device coordinates.
16//
17// # The transformation is given by
18//
19// ```
20// x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0;
21// y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0;
22// ```
23type Matrix struct {
24 _ structs.HostLayout
25
26 Xx float64
27
28 Xy float64
29
30 Yx float64
31
32 Yy float64
33
34 X0 float64
35
36 Y0 float64
37}
38
39var xMatrixGLibType func() types.GType
40
41func MatrixGLibType() types.GType {
42 return xMatrixGLibType()
43}
44
45func (x *Matrix) GoPointer() uintptr {
46 return uintptr(unsafe.Pointer(x))
47}
48
49var xMatrixConcat func(uintptr, *Matrix)
50
51// Changes the transformation represented by @matrix to be the
52// transformation given by first applying transformation
53// given by @new_matrix then applying the original transformation.
54func (x *Matrix) Concat(NewMatrixVar *Matrix) {
55
56 xMatrixConcat(x.GoPointer(), NewMatrixVar)
57
58}
59
60var xMatrixCopy func(uintptr) *Matrix
61
62// Copies a `PangoMatrix`.
63func (x *Matrix) Copy() *Matrix {
64
65 cret := xMatrixCopy(x.GoPointer())
66 return cret
67}
68
69var xMatrixFree func(uintptr)
70
71// Free a `PangoMatrix`.
72func (x *Matrix) Free() {
73
74 xMatrixFree(x.GoPointer())
75
76}
77
78var xMatrixGetFontScaleFactor func(uintptr) float64
79
80// Returns the scale factor of a matrix on the height of the font.
81//
82// That is, the scale factor in the direction perpendicular to the
83// vector that the X coordinate is mapped to. If the scale in the X
84// coordinate is needed as well, use [method@Pango.Matrix.get_font_scale_factors].
85func (x *Matrix) GetFontScaleFactor() float64 {
86
87 cret := xMatrixGetFontScaleFactor(x.GoPointer())
88 return cret
89}
90
91var xMatrixGetFontScaleFactors func(uintptr, *float64, *float64)
92
93// Calculates the scale factor of a matrix on the width and height of the font.
94//
95// That is, @xscale is the scale factor in the direction of the X coordinate,
96// and @yscale is the scale factor in the direction perpendicular to the
97// vector that the X coordinate is mapped to.
98//
99// Note that output numbers will always be non-negative.
100func (x *Matrix) GetFontScaleFactors(XscaleVar *float64, YscaleVar *float64) {
101
102 xMatrixGetFontScaleFactors(x.GoPointer(), XscaleVar, YscaleVar)
103
104}
105
106var xMatrixGetSlantRatio func(uintptr) float64
107
108// Gets the slant ratio of a matrix.
109//
110// For a simple shear matrix in the form:
111//
112// 1 λ
113// 0 1
114//
115// this is simply λ.
116func (x *Matrix) GetSlantRatio() float64 {
117
118 cret := xMatrixGetSlantRatio(x.GoPointer())
119 return cret
120}
121
122var xMatrixRotate func(uintptr, float64)
123
124// Changes the transformation represented by @matrix to be the
125// transformation given by first rotating by @degrees degrees
126// counter-clockwise then applying the original transformation.
127func (x *Matrix) Rotate(DegreesVar float64) {
128
129 xMatrixRotate(x.GoPointer(), DegreesVar)
130
131}
132
133var xMatrixScale func(uintptr, float64, float64)
134
135// Changes the transformation represented by @matrix to be the
136// transformation given by first scaling by @sx in the X direction
137// and @sy in the Y direction then applying the original
138// transformation.
139func (x *Matrix) Scale(ScaleXVar float64, ScaleYVar float64) {
140
141 xMatrixScale(x.GoPointer(), ScaleXVar, ScaleYVar)
142
143}
144
145var xMatrixTransformDistance func(uintptr, float64, float64)
146
147// Transforms the distance vector (@dx,@dy) by @matrix.
148//
149// This is similar to [method@Pango.Matrix.transform_point],
150// except that the translation components of the transformation
151// are ignored. The calculation of the returned vector is as follows:
152//
153// ```
154// dx2 = dx1 * xx + dy1 * xy;
155// dy2 = dx1 * yx + dy1 * yy;
156// ```
157//
158// Affine transformations are position invariant, so the same vector
159// always transforms to the same vector. If (@x1,@y1) transforms
160// to (@x2,@y2) then (@x1+@dx1,@y1+@dy1) will transform to
161// (@x1+@dx2,@y1+@dy2) for all values of @x1 and @x2.
162func (x *Matrix) TransformDistance(DxVar float64, DyVar float64) {
163
164 xMatrixTransformDistance(x.GoPointer(), DxVar, DyVar)
165
166}
167
168var xMatrixTransformPixelRectangle func(uintptr, *Rectangle)
169
170// First transforms the @rect using @matrix, then calculates the bounding box
171// of the transformed rectangle.
172//
173// This function is useful for example when you want to draw a rotated
174// @PangoLayout to an image buffer, and want to know how large the image
175// should be and how much you should shift the layout when rendering.
176//
177// For better accuracy, you should use [method@Pango.Matrix.transform_rectangle]
178// on original rectangle in Pango units and convert to pixels afterward
179// using [func@extents_to_pixels]'s first argument.
180func (x *Matrix) TransformPixelRectangle(RectVar *Rectangle) {
181
182 xMatrixTransformPixelRectangle(x.GoPointer(), RectVar)
183
184}
185
186var xMatrixTransformPoint func(uintptr, float64, float64)
187
188// Transforms the point (@x, @y) by @matrix.
189func (x *Matrix) TransformPoint(XVar float64, YVar float64) {
190
191 xMatrixTransformPoint(x.GoPointer(), XVar, YVar)
192
193}
194
195var xMatrixTransformRectangle func(uintptr, *Rectangle)
196
197// First transforms @rect using @matrix, then calculates the bounding box
198// of the transformed rectangle.
199//
200// This function is useful for example when you want to draw a rotated
201// @PangoLayout to an image buffer, and want to know how large the image
202// should be and how much you should shift the layout when rendering.
203//
204// If you have a rectangle in device units (pixels), use
205// [method@Pango.Matrix.transform_pixel_rectangle].
206//
207// If you have the rectangle in Pango units and want to convert to
208// transformed pixel bounding box, it is more accurate to transform it first
209// (using this function) and pass the result to pango_extents_to_pixels(),
210// first argument, for an inclusive rounded rectangle.
211// However, there are valid reasons that you may want to convert
212// to pixels first and then transform, for example when the transformed
213// coordinates may overflow in Pango units (large matrix translation for
214// example).
215func (x *Matrix) TransformRectangle(RectVar *Rectangle) {
216
217 xMatrixTransformRectangle(x.GoPointer(), RectVar)
218
219}
220
221var xMatrixTranslate func(uintptr, float64, float64)
222
223// Changes the transformation represented by @matrix to be the
224// transformation given by first translating by (@tx, @ty)
225// then applying the original transformation.
226func (x *Matrix) Translate(TxVar float64, TyVar float64) {
227
228 xMatrixTranslate(x.GoPointer(), TxVar, TyVar)
229
230}
231
232func init() {
233 core.SetPackageName("PANGO", "pango")
234 core.SetSharedLibraries("PANGO", []string{"libpango-1.0.so.0"})
235 var libs []uintptr
236 for _, libPath := range core.GetPaths("PANGO") {
237 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
238 if err != nil {
239 panic(err)
240 }
241 libs = append(libs, lib)
242 }
243
244 core.PuregoSafeRegister(&xMatrixGLibType, libs, "pango_matrix_get_type")
245
246 core.PuregoSafeRegister(&xMatrixConcat, libs, "pango_matrix_concat")
247 core.PuregoSafeRegister(&xMatrixCopy, libs, "pango_matrix_copy")
248 core.PuregoSafeRegister(&xMatrixFree, libs, "pango_matrix_free")
249 core.PuregoSafeRegister(&xMatrixGetFontScaleFactor, libs, "pango_matrix_get_font_scale_factor")
250 core.PuregoSafeRegister(&xMatrixGetFontScaleFactors, libs, "pango_matrix_get_font_scale_factors")
251 core.PuregoSafeRegister(&xMatrixGetSlantRatio, libs, "pango_matrix_get_slant_ratio")
252 core.PuregoSafeRegister(&xMatrixRotate, libs, "pango_matrix_rotate")
253 core.PuregoSafeRegister(&xMatrixScale, libs, "pango_matrix_scale")
254 core.PuregoSafeRegister(&xMatrixTransformDistance, libs, "pango_matrix_transform_distance")
255 core.PuregoSafeRegister(&xMatrixTransformPixelRectangle, libs, "pango_matrix_transform_pixel_rectangle")
256 core.PuregoSafeRegister(&xMatrixTransformPoint, libs, "pango_matrix_transform_point")
257 core.PuregoSafeRegister(&xMatrixTransformRectangle, libs, "pango_matrix_transform_rectangle")
258 core.PuregoSafeRegister(&xMatrixTranslate, libs, "pango_matrix_translate")
259
260}