Panda3D
|
00001 // Filename: pnmTextGlyph.I 00002 // Created by: drose (07Sep03) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: PNMTextGlyph::get_advance 00018 // Access: Public 00019 // Description: Returns the number of pixels by which the pen should 00020 // be advanced after rendering this glyph. 00021 //////////////////////////////////////////////////////////////////// 00022 INLINE int PNMTextGlyph:: 00023 get_advance() const { 00024 return _int_advance; 00025 } 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: PNMTextGlyph::get_left 00029 // Access: Public 00030 // Description: Returns the x coordinate of the leftmost pixel in the 00031 // glyph. 00032 //////////////////////////////////////////////////////////////////// 00033 INLINE int PNMTextGlyph:: 00034 get_left() const { 00035 return _left; 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: PNMTextGlyph::get_right 00040 // Access: Public 00041 // Description: Returns the x coordinate of the rightmost pixel in the 00042 // glyph. 00043 //////////////////////////////////////////////////////////////////// 00044 INLINE int PNMTextGlyph:: 00045 get_right() const { 00046 return _left + _image.get_x_size(); 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: PNMTextGlyph::get_bottom 00051 // Access: Public 00052 // Description: Returns the y coordinate of the bottommost pixel in 00053 // the glyph. 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE int PNMTextGlyph:: 00056 get_bottom() const { 00057 return _top + _image.get_y_size(); 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: PNMTextGlyph::get_top 00062 // Access: Public 00063 // Description: Returns the y coordinate of the topmost pixel in the 00064 // glyph. 00065 //////////////////////////////////////////////////////////////////// 00066 INLINE int PNMTextGlyph:: 00067 get_top() const { 00068 return _top; 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: PNMTextGlyph::get_height 00073 // Access: Public 00074 // Description: Returns the height of the glyph in pixels. 00075 //////////////////////////////////////////////////////////////////// 00076 INLINE int PNMTextGlyph:: 00077 get_height() const { 00078 return _image.get_y_size(); 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: PNMTextGlyph::get_width 00083 // Access: Public 00084 // Description: Returns the width of the glyph in pixels. 00085 //////////////////////////////////////////////////////////////////// 00086 INLINE int PNMTextGlyph:: 00087 get_width() const { 00088 return _image.get_x_size(); 00089 } 00090 00091 //////////////////////////////////////////////////////////////////// 00092 // Function: PNMTextGlyph::get_value 00093 // Access: Public 00094 // Description: Returns the value of the indicated pixel of the 00095 // glyph. The result is in the range [0, 1], where 0 00096 // indicates the pixel is not part of the glyph, and 1 00097 // indicates it is. Intermediate values are used to 00098 // represent antialiasing. 00099 //////////////////////////////////////////////////////////////////// 00100 INLINE double PNMTextGlyph:: 00101 get_value(int x, int y) const { 00102 nassertr(x >= 0 && x < get_width() && 00103 y >= 0 && y < get_height(), 0.0); 00104 // By convention, the "value" attribute is stored in the blue 00105 // component. 00106 return _image.get_blue(x, y); 00107 } 00108 00109 //////////////////////////////////////////////////////////////////// 00110 // Function: PNMTextGlyph::get_interior_flag 00111 // Access: Public 00112 // Description: Returns true if the indicated pixel represents a 00113 // pixel in the interior of a hollow font, false 00114 // otherwise. 00115 //////////////////////////////////////////////////////////////////// 00116 INLINE bool PNMTextGlyph:: 00117 get_interior_flag(int x, int y) const { 00118 nassertr(x >= 0 && x < get_width() && 00119 y >= 0 && y < get_height(), false); 00120 // By convention, the "interior_value" attribute is stored in the red 00121 // component. 00122 return _image.get_red_val(x, y) != 0; 00123 }