MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / to_rgba

Method to_rgba

site-packages/matplotlib/mathtext.py:3299–3329  ·  view source on GitHub ↗

*texstr* A valid mathtext string, e.g., r'IQ: $\\sigma_i=15$' *color* Any matplotlib color argument *dpi* The dots-per-inch to render the text *fontsize* The font size in points Returns a tuple (*array*, *de

(self, texstr, color='black', dpi=120, fontsize=14)

Source from the content-addressed store, hash-verified

3297 return x, depth
3298
3299 def to_rgba(self, texstr, color='black', dpi=120, fontsize=14):
3300 """
3301 *texstr*
3302 A valid mathtext string, e.g., r'IQ: $\\sigma_i=15$'
3303
3304 *color*
3305 Any matplotlib color argument
3306
3307 *dpi*
3308 The dots-per-inch to render the text
3309
3310 *fontsize*
3311 The font size in points
3312
3313 Returns a tuple (*array*, *depth*)
3314
3315 - *array* is an NxM uint8 alpha ubyte mask array of
3316 rasterized tex.
3317
3318 - depth is the offset of the baseline from the bottom of the
3319 image in pixels.
3320 """
3321 x, depth = self.to_mask(texstr, dpi=dpi, fontsize=fontsize)
3322
3323 r, g, b, a = mcolors.to_rgba(color)
3324 RGBA = np.zeros((x.shape[0], x.shape[1], 4), dtype=np.uint8)
3325 RGBA[:, :, 0] = 255 * r
3326 RGBA[:, :, 1] = 255 * g
3327 RGBA[:, :, 2] = 255 * b
3328 RGBA[:, :, 3] = x
3329 return RGBA, depth
3330
3331 def to_png(self, filename, texstr, color='black', dpi=120, fontsize=14):
3332 """

Callers 1

to_pngMethod · 0.95

Calls 1

to_maskMethod · 0.95

Tested by

no test coverage detected