r""" Return latex's rendering of the tex string as an RGBA array. Examples -------- >>> texmanager = TexManager() >>> s = r"\TeX\ is $\displaystyle\sum_n\frac{-e^{i\pi}}{2^n}$!" >>> Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1, 0, 0))
(cls, tex, fontsize=None, dpi=None, rgb=(0, 0, 0))
| 346 | |
| 347 | @classmethod |
| 348 | def get_rgba(cls, tex, fontsize=None, dpi=None, rgb=(0, 0, 0)): |
| 349 | r""" |
| 350 | Return latex's rendering of the tex string as an RGBA array. |
| 351 | |
| 352 | Examples |
| 353 | -------- |
| 354 | >>> texmanager = TexManager() |
| 355 | >>> s = r"\TeX\ is $\displaystyle\sum_n\frac{-e^{i\pi}}{2^n}$!" |
| 356 | >>> Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1, 0, 0)) |
| 357 | """ |
| 358 | alpha = cls.get_grey(tex, fontsize, dpi) |
| 359 | rgba = np.empty((*alpha.shape, 4)) |
| 360 | rgba[..., :3] = mpl.colors.to_rgb(rgb) |
| 361 | rgba[..., -1] = alpha |
| 362 | return rgba |
| 363 | |
| 364 | @classmethod |
| 365 | def get_text_width_height_descent(cls, tex, fontsize, renderer=None): |