Panda3D
 All Classes Functions Variables Enumerations
pnmTextGlyph.I
1 // Filename: pnmTextGlyph.I
2 // Created by: drose (07Sep03)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PNMTextGlyph::get_advance
18 // Access: Public
19 // Description: Returns the number of pixels by which the pen should
20 // be advanced after rendering this glyph.
21 ////////////////////////////////////////////////////////////////////
22 INLINE int PNMTextGlyph::
23 get_advance() const {
24  return _int_advance;
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: PNMTextGlyph::get_left
29 // Access: Public
30 // Description: Returns the x coordinate of the leftmost pixel in the
31 // glyph.
32 ////////////////////////////////////////////////////////////////////
33 INLINE int PNMTextGlyph::
34 get_left() const {
35  return _left;
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: PNMTextGlyph::get_right
40 // Access: Public
41 // Description: Returns the x coordinate of the rightmost pixel in the
42 // glyph.
43 ////////////////////////////////////////////////////////////////////
44 INLINE int PNMTextGlyph::
45 get_right() const {
46  return _left + _image.get_x_size();
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: PNMTextGlyph::get_bottom
51 // Access: Public
52 // Description: Returns the y coordinate of the bottommost pixel in
53 // the glyph.
54 ////////////////////////////////////////////////////////////////////
55 INLINE int PNMTextGlyph::
56 get_bottom() const {
57  return _top + _image.get_y_size();
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: PNMTextGlyph::get_top
62 // Access: Public
63 // Description: Returns the y coordinate of the topmost pixel in the
64 // glyph.
65 ////////////////////////////////////////////////////////////////////
66 INLINE int PNMTextGlyph::
67 get_top() const {
68  return _top;
69 }
70 
71 ////////////////////////////////////////////////////////////////////
72 // Function: PNMTextGlyph::get_height
73 // Access: Public
74 // Description: Returns the height of the glyph in pixels.
75 ////////////////////////////////////////////////////////////////////
76 INLINE int PNMTextGlyph::
77 get_height() const {
78  return _image.get_y_size();
79 }
80 
81 ////////////////////////////////////////////////////////////////////
82 // Function: PNMTextGlyph::get_width
83 // Access: Public
84 // Description: Returns the width of the glyph in pixels.
85 ////////////////////////////////////////////////////////////////////
86 INLINE int PNMTextGlyph::
87 get_width() const {
88  return _image.get_x_size();
89 }
90 
91 ////////////////////////////////////////////////////////////////////
92 // Function: PNMTextGlyph::get_value
93 // Access: Public
94 // Description: Returns the value of the indicated pixel of the
95 // glyph. The result is in the range [0, 1], where 0
96 // indicates the pixel is not part of the glyph, and 1
97 // indicates it is. Intermediate values are used to
98 // represent antialiasing.
99 ////////////////////////////////////////////////////////////////////
100 INLINE double PNMTextGlyph::
101 get_value(int x, int y) const {
102  nassertr(x >= 0 && x < get_width() &&
103  y >= 0 && y < get_height(), 0.0);
104  // By convention, the "value" attribute is stored in the blue
105  // component.
106  return _image.get_blue(x, y);
107 }
108 
109 ////////////////////////////////////////////////////////////////////
110 // Function: PNMTextGlyph::get_interior_flag
111 // Access: Public
112 // Description: Returns true if the indicated pixel represents a
113 // pixel in the interior of a hollow font, false
114 // otherwise.
115 ////////////////////////////////////////////////////////////////////
116 INLINE bool PNMTextGlyph::
117 get_interior_flag(int x, int y) const {
118  nassertr(x >= 0 && x < get_width() &&
119  y >= 0 && y < get_height(), false);
120  // By convention, the "interior_value" attribute is stored in the red
121  // component.
122  return _image.get_red_val(x, y) != 0;
123 }
double get_value(int x, int y) const
Returns the value of the indicated pixel of the glyph.
Definition: pnmTextGlyph.I:101
int get_right() const
Returns the x coordinate of the rightmost pixel in the glyph.
Definition: pnmTextGlyph.I:45
int get_top() const
Returns the y coordinate of the topmost pixel in the glyph.
Definition: pnmTextGlyph.I:67
int get_height() const
Returns the height of the glyph in pixels.
Definition: pnmTextGlyph.I:77
float get_blue(int x, int y) const
Returns the blue component color at the indicated pixel.
Definition: pnmImage.I:913
int get_x_size() const
Returns the number of pixels in the X direction.
bool get_interior_flag(int x, int y) const
Returns true if the indicated pixel represents a pixel in the interior of a hollow font...
Definition: pnmTextGlyph.I:117
int get_y_size() const
Returns the number of pixels in the Y direction.
int get_width() const
Returns the width of the glyph in pixels.
Definition: pnmTextGlyph.I:87
int get_left() const
Returns the x coordinate of the leftmost pixel in the glyph.
Definition: pnmTextGlyph.I:34
int get_advance() const
Returns the number of pixels by which the pen should be advanced after rendering this glyph...
Definition: pnmTextGlyph.I:23
int get_bottom() const
Returns the y coordinate of the bottommost pixel in the glyph.
Definition: pnmTextGlyph.I:56
xelval get_red_val(int x, int y) const
Returns the red component color at the indicated pixel.
Definition: pnmImage.I:450