Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bed200a

Browse files
committed
svn path=/trunk/matplotlib/; revision=2729
1 parent 50805fb commit bed200a

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2006-08-30 ft2font.cpp: Added draw_rect_filled method (now used by mathtext2
2+
to draw the fraction bar) to FT2Font - ES
3+
14
2006-08-29 setupext.py: wrap calls to tk.getvar() with str(). On some
25
systems, getvar returns a Tcl_Obj instead of a string - DSD
36

lib/matplotlib/mathtext2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def render(self, x, y):
615615
y + self.ymax)
616616
#print coords
617617
#print "\n".join(repr(self.__dict__).split(","))
618-
font.draw_rect(*coords)
618+
font.draw_rect_filled(*coords)
619619

620620

621621
# Main parser functions

src/ft2font.cpp

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ FT2Font::write_bitmap(const Py::Tuple & args) {
926926
}
927927

928928
char FT2Font::draw_rect__doc__[] =
929-
"draw_bbox(x0, y0, x1, y1)\n"
929+
"draw_rect(x0, y0, x1, y1)\n"
930930
"\n"
931931
"Draw a rect to the image. It is your responsibility to set the dimensions\n"
932932
"of the image, eg, with set_bitmap_size\n"
@@ -951,18 +951,52 @@ FT2Font::draw_rect(const Py::Tuple & args) {
951951
y0>iheight || y1>iheight )
952952
throw Py::ValueError("Rect coords outside image bounds");
953953

954-
for (long i=x0; i<x1; ++i) {
954+
for (long i=x0; i<x1+1; ++i) {
955955
image.buffer[i + y0*iwidth] = 255;
956956
image.buffer[i + y1*iwidth] = 255;
957957
}
958958

959-
for (long j=y0; j<y1; ++j) {
959+
for (long j=y0+1; j<y1; ++j) {
960960
image.buffer[x0 + j*iwidth] = 255;
961961
image.buffer[x1 + j*iwidth] = 255;
962962
}
963963
return Py::Object();
964964
}
965965

966+
char FT2Font::draw_rect_filled__doc__[] =
967+
"draw_rect_filled(x0, y0, x1, y1)\n"
968+
"\n"
969+
"Draw a filled rect to the image. It is your responsibility to set the\n"
970+
"dimensions of the image, eg, with set_bitmap_size\n"
971+
"\n"
972+
;
973+
Py::Object
974+
FT2Font::draw_rect_filled(const Py::Tuple & args) {
975+
_VERBOSE("FT2Font::draw_rect_filled");
976+
977+
args.verify_length(4);
978+
979+
long x0 = Py::Int(args[0]);
980+
long y0 = Py::Int(args[1]);
981+
long x1 = Py::Int(args[2]);
982+
long y1 = Py::Int(args[3]);
983+
984+
FT_Int iwidth = (FT_Int)image.width;
985+
FT_Int iheight = (FT_Int)image.height;
986+
987+
if ( x0<0 || y0<0 || x1<0 || y1<0 ||
988+
x0>iwidth || x1>iwidth ||
989+
y0>iheight || y1>iheight )
990+
throw Py::ValueError("Rect coords outside image bounds");
991+
992+
for (long j=y0; j<y1; ++j) {
993+
for (long i=x0; i<x1+1; ++i) {
994+
image.buffer[i + j*iwidth] = 255;
995+
}
996+
}
997+
return Py::Object();
998+
}
999+
9661000
char FT2Font::image_as_str__doc__[] =
9671001
"width, height, s = image_as_str()\n"
9681002
"\n"
@@ -1562,6 +1596,8 @@ FT2Font::init_type() {
15621596
FT2Font::load_char__doc__);
15631597
add_varargs_method("draw_rect",&FT2Font::draw_rect,
15641598
FT2Font::draw_rect__doc__);
1599+
add_varargs_method("draw_rect_filled",&FT2Font::draw_rect_filled,
1600+
FT2Font::draw_rect_filled__doc__);
15651601
add_varargs_method("draw_glyph_to_bitmap", &FT2Font::draw_glyph_to_bitmap,
15661602
FT2Font::draw_glyph_to_bitmap__doc__);
15671603
add_varargs_method("draw_glyphs_to_bitmap", &FT2Font::draw_glyphs_to_bitmap,

src/ft2font.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class FT2Font : public Py::PythonExtension<FT2Font> {
6565
Py::Object get_descent(const Py::Tuple & args);
6666
Py::Object write_bitmap(const Py::Tuple & args);
6767
Py::Object draw_rect(const Py::Tuple & args);
68+
Py::Object draw_rect_filled(const Py::Tuple & args);
6869
Py::Object image_as_str(const Py::Tuple & args);
6970
Py::Object get_xys(const Py::Tuple & args);
7071
Py::Object draw_glyphs_to_bitmap(const Py::Tuple & args);
@@ -110,6 +111,7 @@ class FT2Font : public Py::PythonExtension<FT2Font> {
110111
static char get_kerning__doc__ [];
111112
static char write_bitmap__doc__ [];
112113
static char draw_rect__doc__ [];
114+
static char draw_rect_filled__doc__ [];
113115
static char image_as_str__doc__ [];
114116
static char draw_glyphs_to_bitmap__doc__ [];
115117
static char get_xys__doc__ [];

0 commit comments

Comments
 (0)