An LGPL/GPL-licensed artwork library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

art_uta.c 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Libart_LGPL - library of basic graphic primitives
  2. * Copyright (C) 1998 Raph Levien
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. */
  19. #include "config.h"
  20. #include "art_uta.h"
  21. #include <string.h>
  22. #include "art_misc.h"
  23. /**
  24. * art_uta_new: Allocate a new uta.
  25. * @x0: Left coordinate of uta.
  26. * @y0: Top coordinate of uta.
  27. * @x1: Right coordinate of uta.
  28. * @y1: Bottom coordinate of uta.
  29. *
  30. * Allocates a new microtile array. The arguments are in units of
  31. * tiles, not pixels.
  32. *
  33. * Returns: the newly allocated #ArtUta.
  34. **/
  35. ArtUta *
  36. art_uta_new (int x0, int y0, int x1, int y1)
  37. {
  38. ArtUta *uta;
  39. uta = art_new (ArtUta, 1);
  40. uta->x0 = x0;
  41. uta->y0 = y0;
  42. uta->width = x1 - x0;
  43. uta->height = y1 - y0;
  44. uta->utiles = art_new (ArtUtaBbox, uta->width * uta->height);
  45. memset (uta->utiles, 0, uta->width * uta->height * sizeof(ArtUtaBbox));
  46. return uta;
  47. }
  48. /**
  49. * art_uta_new_coords: Allocate a new uta, based on pixel coordinates.
  50. * @x0: Left coordinate of uta.
  51. * @y0: Top coordinate of uta.
  52. * @x1: Right coordinate of uta.
  53. * @y1: Bottom coordinate of uta.
  54. *
  55. * Allocates a new microtile array. The arguments are in pixels
  56. *
  57. * Returns: the newly allocated #ArtUta.
  58. **/
  59. ArtUta *
  60. art_uta_new_coords (int x0, int y0, int x1, int y1)
  61. {
  62. return art_uta_new (x0 >> ART_UTILE_SHIFT, y0 >> ART_UTILE_SHIFT,
  63. 1 + (x1 >> ART_UTILE_SHIFT),
  64. 1 + (y1 >> ART_UTILE_SHIFT));
  65. }
  66. /**
  67. * art_uta_free: Free a uta.
  68. * @uta: The uta to free.
  69. *
  70. * Frees the microtile array structure, including the actual microtile
  71. * data.
  72. **/
  73. void
  74. art_uta_free (ArtUta *uta)
  75. {
  76. art_free (uta->utiles);
  77. art_free (uta);
  78. }
  79. /* User to Aardvark! */