pango-matrix.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* Pango
  2. * pango-matrix.h: Matrix manipulation routines
  3. *
  4. * Copyright (C) 2002, 2006 Red Hat Software
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __PANGO_MATRIX_H__
  22. #define __PANGO_MATRIX_H__
  23. #include <glib.h>
  24. #include <glib-object.h>
  25. G_BEGIN_DECLS
  26. typedef struct _PangoMatrix PangoMatrix;
  27. /**
  28. * PangoMatrix:
  29. * @xx: 1st component of the transformation matrix
  30. * @xy: 2nd component of the transformation matrix
  31. * @yx: 3rd component of the transformation matrix
  32. * @yy: 4th component of the transformation matrix
  33. * @x0: x translation
  34. * @y0: y translation
  35. *
  36. * A `PangoMatrix` specifies a transformation between user-space
  37. * and device coordinates.
  38. *
  39. * The transformation is given by
  40. *
  41. * ```
  42. * x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0;
  43. * y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0;
  44. * ```
  45. *
  46. * Since: 1.6
  47. */
  48. struct _PangoMatrix
  49. {
  50. double xx;
  51. double xy;
  52. double yx;
  53. double yy;
  54. double x0;
  55. double y0;
  56. };
  57. #define PANGO_TYPE_MATRIX (pango_matrix_get_type ())
  58. /**
  59. * PANGO_MATRIX_INIT:
  60. *
  61. * Constant that can be used to initialize a `PangoMatrix` to
  62. * the identity transform.
  63. *
  64. * ```
  65. * PangoMatrix matrix = PANGO_MATRIX_INIT;
  66. * pango_matrix_rotate (&matrix, 45.);
  67. * ```
  68. *
  69. * Since: 1.6
  70. **/
  71. #define PANGO_MATRIX_INIT { 1., 0., 0., 1., 0., 0. }
  72. /* for PangoRectangle */
  73. #include <pango/pango-types.h>
  74. PANGO_AVAILABLE_IN_1_6
  75. GType pango_matrix_get_type (void) G_GNUC_CONST;
  76. PANGO_AVAILABLE_IN_1_6
  77. PangoMatrix *pango_matrix_copy (const PangoMatrix *matrix);
  78. PANGO_AVAILABLE_IN_1_6
  79. void pango_matrix_free (PangoMatrix *matrix);
  80. PANGO_AVAILABLE_IN_1_6
  81. void pango_matrix_translate (PangoMatrix *matrix,
  82. double tx,
  83. double ty);
  84. PANGO_AVAILABLE_IN_1_6
  85. void pango_matrix_scale (PangoMatrix *matrix,
  86. double scale_x,
  87. double scale_y);
  88. PANGO_AVAILABLE_IN_1_6
  89. void pango_matrix_rotate (PangoMatrix *matrix,
  90. double degrees);
  91. PANGO_AVAILABLE_IN_1_6
  92. void pango_matrix_concat (PangoMatrix *matrix,
  93. const PangoMatrix *new_matrix);
  94. PANGO_AVAILABLE_IN_1_16
  95. void pango_matrix_transform_point (const PangoMatrix *matrix,
  96. double *x,
  97. double *y);
  98. PANGO_AVAILABLE_IN_1_16
  99. void pango_matrix_transform_distance (const PangoMatrix *matrix,
  100. double *dx,
  101. double *dy);
  102. PANGO_AVAILABLE_IN_1_16
  103. void pango_matrix_transform_rectangle (const PangoMatrix *matrix,
  104. PangoRectangle *rect);
  105. PANGO_AVAILABLE_IN_1_16
  106. void pango_matrix_transform_pixel_rectangle (const PangoMatrix *matrix,
  107. PangoRectangle *rect);
  108. PANGO_AVAILABLE_IN_1_12
  109. double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix) G_GNUC_PURE;
  110. PANGO_AVAILABLE_IN_1_38
  111. void pango_matrix_get_font_scale_factors (const PangoMatrix *matrix,
  112. double *xscale, double *yscale);
  113. PANGO_AVAILABLE_IN_1_50
  114. double pango_matrix_get_slant_ratio (const PangoMatrix *matrix) G_GNUC_PURE;
  115. G_END_DECLS
  116. #endif /* __PANGO_MATRIX_H__ */