|
26 | 26 |
|
27 | 27 | import threading
|
28 | 28 | import numpy as np
|
29 |
| - |
| 29 | +from math import radians, cos, sin |
30 | 30 | from matplotlib import verbose, rcParams
|
31 | 31 | from matplotlib.backend_bases import RendererBase,\
|
32 | 32 | FigureManagerBase, FigureCanvasBase
|
@@ -174,10 +174,10 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
|
174 | 174 | ox, oy, width, height, descent, font_image, used_characters = \
|
175 | 175 | self.mathtext_parser.parse(s, self.dpi, prop)
|
176 | 176 |
|
177 |
| - xd = descent * np.sin(np.deg2rad(angle)) |
178 |
| - yd = descent * np.cos(np.deg2rad(angle)) |
179 |
| - x = np.round(x + ox + xd) |
180 |
| - y = np.round(y - oy + yd) |
| 177 | + xd = descent * sin(radians(angle)) |
| 178 | + yd = descent * cos(radians(angle)) |
| 179 | + x = round(x + ox + xd) |
| 180 | + y = round(y - oy + yd) |
181 | 181 | self._renderer.draw_text_image(font_image, x, y + 1, angle, gc)
|
182 | 182 |
|
183 | 183 | def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
|
@@ -205,12 +205,12 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
|
205 | 205 | xo, yo = font.get_bitmap_offset()
|
206 | 206 | xo /= 64.0
|
207 | 207 | yo /= 64.0
|
208 |
| - xd = -d * np.sin(np.deg2rad(angle)) |
209 |
| - yd = d * np.cos(np.deg2rad(angle)) |
| 208 | + xd = -d * sin(radians(angle)) |
| 209 | + yd = d * cos(radians(angle)) |
210 | 210 |
|
211 | 211 | #print x, y, int(x), int(y), s
|
212 | 212 | self._renderer.draw_text_image(
|
213 |
| - font, np.round(x - xd + xo), np.round(y + yd + yo) + 1, angle, gc) |
| 213 | + font, round(x - xd + xo), round(y + yd + yo) + 1, angle, gc) |
214 | 214 |
|
215 | 215 | def get_text_width_height_descent(self, s, prop, ismath):
|
216 | 216 | """
|
@@ -255,10 +255,10 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
|
255 | 255 | Z = np.array(Z * 255.0, np.uint8)
|
256 | 256 |
|
257 | 257 | w, h, d = self.get_text_width_height_descent(s, prop, ismath)
|
258 |
| - xd = d * np.sin(np.deg2rad(angle)) |
259 |
| - yd = d * np.cos(np.deg2rad(angle)) |
260 |
| - x = np.round(x + xd) |
261 |
| - y = np.round(y + yd) |
| 258 | + xd = d * sin(radians(angle)) |
| 259 | + yd = d * cos(radians(angle)) |
| 260 | + x = round(x + xd) |
| 261 | + y = round(y + yd) |
262 | 262 |
|
263 | 263 | self._renderer.draw_text_image(Z, x, y, angle, gc)
|
264 | 264 |
|
|
0 commit comments