The BIG graph update
[rrdtool.git] / libraries / libart_lgpl-2.3.7 / art_uta.c
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
20 #include <string.h>
21 #include "art_misc.h"
22 #include "art_uta.h"
23
24 /**
25  * art_uta_new: Allocate a new uta.
26  * @x0: Left coordinate of uta.
27  * @y0: Top coordinate of uta.
28  * @x1: Right coordinate of uta.
29  * @y1: Bottom coordinate of uta.
30  *
31  * Allocates a new microtile array. The arguments are in units of
32  * tiles, not pixels.
33  *
34  * Returns: the newly allocated #ArtUta.
35  **/
36 ArtUta *
37 art_uta_new (int x0, int y0, int x1, int y1)
38 {
39   ArtUta *uta;
40
41   uta = art_new (ArtUta, 1);
42   uta->x0 = x0;
43   uta->y0 = y0;
44   uta->width = x1 - x0;
45   uta->height = y1 - y0;
46
47   uta->utiles = art_new (ArtUtaBbox, uta->width * uta->height);
48
49   memset (uta->utiles, 0, uta->width * uta->height * sizeof(ArtUtaBbox));
50   return uta;
51   }
52
53 /**
54  * art_uta_new_coords: Allocate a new uta, based on pixel coordinates.
55  * @x0: Left coordinate of uta.
56  * @y0: Top coordinate of uta.
57  * @x1: Right coordinate of uta.
58  * @y1: Bottom coordinate of uta.
59  *
60  * Allocates a new microtile array. The arguments are in pixels
61  *
62  * Returns: the newly allocated #ArtUta.
63  **/
64 ArtUta *
65 art_uta_new_coords (int x0, int y0, int x1, int y1)
66 {
67   return art_uta_new (x0 >> ART_UTILE_SHIFT, y0 >> ART_UTILE_SHIFT,
68                       1 + (x1 >> ART_UTILE_SHIFT),
69                       1 + (y1 >> ART_UTILE_SHIFT));
70 }
71
72 /**
73  * art_uta_free: Free a uta.
74  * @uta: The uta to free.
75  *
76  * Frees the microtile array structure, including the actual microtile
77  * data.
78  **/
79 void
80 art_uta_free (ArtUta *uta)
81 {
82   art_free (uta->utiles);
83   art_free (uta);
84 }
85
86 /* User to Aardvark! */