Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 06e217c

Browse files
Remove self-comments made to document my changes
1 parent 8991c7b commit 06e217c

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

matplotlib_pyodide/html5_canvas_backend.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -332,51 +332,40 @@ def _draw_math_text_path(self, gc, x, y, s, prop, angle):
332332
angle : float
333333
The rotation angle in degrees
334334
"""
335-
# Parse the math text to get paths and metrics
336335
width, height, depth, glyphs, rects = self.mathtext_parser.parse(
337336
s, dpi=self.dpi, prop=prop
338337
)
339338

340-
# Save the canvas state
341339
self.ctx.save()
342340

343-
# Move to text position and apply rotation if needed
344341
self.ctx.translate(x, self.height - y)
345342
if angle != 0:
346343
self.ctx.rotate(-math.radians(angle))
347344

348-
# Set up text rendering style
349345
self.ctx.fillStyle = self._matplotlib_color_to_CSS(
350346
gc.get_rgb(), gc.get_alpha(), gc.get_forced_alpha()
351347
)
352348

353-
# Draw each glyph in the mathematical expression
354349
for font, fontsize, _, ox, oy in glyphs:
355-
# Move to glyph position
356350
self.ctx.save()
357351
self.ctx.translate(ox, -oy)
358352

359-
# Get the glyph's path data
360353
font.set_size(fontsize, self.dpi)
361354
verts, codes = font.get_path()
362355

363356
verts = verts * fontsize / font.units_per_EM
364357

365-
# Convert the glyph to a Path object
366358
path = Path(verts, codes)
367359

368-
# Draw the path
369360
transform = Affine2D().scale(1.0, -1.0)
370361
self._path_helper(self.ctx, path, transform)
371362
self.ctx.fill()
372363

373364
self.ctx.restore()
374365

375-
# Draw rectangles (fraction bars, roots, etc.)
376366
for x1, y1, x2, y2 in rects:
377367
self.ctx.fillRect(x1, -y2, x2 - x1, y2 - y1)
378368

379-
# Restore the canvas state
380369
self.ctx.restore()
381370

382371
def _draw_math_text(self, gc, x, y, s, prop, angle):
@@ -399,13 +388,11 @@ def _draw_math_text(self, gc, x, y, s, prop, angle):
399388
The rotation angle in degrees
400389
"""
401390
try:
402-
# Try rendering directly with paths first
403391
self._draw_math_text_path(gc, x, y, s, prop, angle)
404392
except Exception as e:
405-
# If path rendering fails, fall back to image-based approach
393+
# If path rendering fails, we fall back to image-based approach
406394
print(f"Path rendering failed, falling back to image: {str(e)}")
407395

408-
# Get RGBA array using the existing image-based method
409396
rgba, depth = self._math_to_rgba(s, prop, gc.get_rgb())
410397

411398
angle = math.radians(angle)

0 commit comments

Comments
 (0)