source: trunk/third/mozilla/other-licenses/libart_lgpl/art_rect_svp.c @ 22325

Revision 22325, 2.2 KB checked in by rbasch, 19 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r22324, which included commits to RCS files with non-trunk default branches.
RevLine 
[22324]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 "config.h"
21#include "art_rect_svp.h"
22
23#include "art_misc.h"
24#include "art_svp.h"
25#include "art_rect.h"
26
27#ifndef MAX
28#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
29#endif /* MAX */
30
31#ifndef MIN
32#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
33#endif /* MIN */
34
35/**
36 * art_drect_svp: Find the bounding box of a sorted vector path.
37 * @bbox: Where to store the bounding box.
38 * @svp: The SVP.
39 *
40 * Finds the bounding box of the SVP.
41 **/
42void
43art_drect_svp (ArtDRect *bbox, const ArtSVP *svp)
44{
45  int i;
46
47  if (svp->n_segs == 0)
48    {
49  bbox->x0 = 0;
50  bbox->y0 = 0;
51  bbox->x1 = 0;
52  bbox->y1 = 0;
53      return;
54    }
55
56  art_drect_copy (bbox, &svp->segs[0].bbox);
57
58  for (i = 1; i < svp->n_segs; i++)
59    {
60      bbox->x0 = MIN (bbox->x0, svp->segs[i].bbox.x0);
61      bbox->y0 = MIN (bbox->y0, svp->segs[i].bbox.y0);
62      bbox->x1 = MAX (bbox->x1, svp->segs[i].bbox.x1);
63      bbox->y1 = MAX (bbox->y1, svp->segs[i].bbox.y1);
64    }
65}
66
67/**
68 * art_drect_svp_union: Compute the bounding box of the svp and union it in to the existing bounding box.
69 * @bbox: Initial boundin box and where to store the bounding box.
70 * @svp: The SVP.
71 *
72 * Finds the bounding box of the SVP, computing its union with an
73 * existing bbox.
74 **/
75void
76art_drect_svp_union (ArtDRect *bbox, const ArtSVP *svp)
77{
78  ArtDRect svp_bbox;
79
80  art_drect_svp (&svp_bbox, svp);
81  art_drect_union (bbox, bbox, &svp_bbox);
82}
Note: See TracBrowser for help on using the repository browser.