home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / fontutil.6 / fontutil / fontutils-0.6 / include / bounding-box.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-14  |  2.1 KB  |  64 lines

  1. /* bounding-box.h: operations on both real- and integer-valued bounding boxes.
  2.  
  3. Copyright (C) 1992 Free Software Foundation, Inc.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef BOUNDING_BOX_H
  20. #define BOUNDING_BOX_H
  21.  
  22. #include "types.h"
  23.  
  24.  
  25. /* The bounding box's numbers are usually in Cartesian/Metafont
  26.    coordinates: (0,0) is towards the lower left.  */
  27. typedef struct
  28. {
  29.   signed_4_bytes min_row, max_row;
  30.   signed_4_bytes min_col, max_col;
  31. } bounding_box_type;
  32.  
  33. typedef struct
  34. {
  35.   real min_row, max_row;
  36.   real min_col, max_col;
  37. } real_bounding_box_type;
  38.  
  39. /* These accessing macros work for both types of bounding boxes, since
  40.    the member names are the same.  */
  41. #define MIN_ROW(bb) ((bb).min_row)
  42. #define MAX_ROW(bb) ((bb).max_row)
  43. #define MIN_COL(bb) ((bb).min_col)
  44. #define MAX_COL(bb) ((bb).max_col)
  45.  
  46. /* See the comments at `get_character_bitmap' in gf_input.c for why the
  47.    width and height are treated asymetrically.  */
  48. #define BB_WIDTH(bb) (MAX_COL (bb) - MIN_COL (bb))
  49. #define BB_HEIGHT(bb) (MAX_ROW (bb) - MIN_ROW (bb) + 1)
  50.  
  51.  
  52. /* Convert a dimensions structure to an integer bounding box, and vice
  53.    versa.  */
  54. extern const bounding_box_type dimensions_to_bb (dimensions_type);
  55. extern const dimensions_type bb_to_dimensions (bounding_box_type);
  56.  
  57.  
  58. /* Update the bounding box BB from the point P.  */
  59. extern void update_real_bounding_box (real_bounding_box_type *bb,
  60.                                       real_coordinate_type p);
  61. extern void update_bounding_box (bounding_box_type *bb, coordinate_type p);
  62.  
  63. #endif /* not BOUNDING_BOX_H */
  64.