Programmatically generate SVG (vector) images, animations, and interactive Jupyter widgets

Update example for hyperbolic~=2.0

+7 -13
+7 -13
README.md
··· 333 333 ```python 334 334 import drawsvg as draw 335 335 from drawsvg.widgets import DrawingWidget 336 - import hyperbolic.poincare.shapes as hyper # python3 -m pip install hyperbolic 336 + import hyperbolic.poincare as hyper # python3 -m pip install hyperbolic 337 337 from hyperbolic import euclid 338 - 339 - # Patch the hyperbolic package for drawsvg version 2 340 - patch = lambda m: lambda self, **kw: m(self, draw, **kw) 341 - hyper.Circle.to_drawables = patch(hyper.Circle.toDrawables) 342 - hyper.Line.to_drawables = patch(hyper.Line.toDrawables) 343 - euclid.Arc.Arc.drawToPath = lambda self, path, includeM=True, includeL=False: path.arc(self.cx, self.cy, self.r, self.startDeg, self.endDeg, cw=not self.cw, include_m=includeM, include_l=includeL) 344 338 345 339 # Create drawing 346 340 d = draw.Drawing(2, 2, origin='center', context=draw.Context(invert_y=True)) ··· 356 350 for x1, y1 in points: 357 351 for x2, y2 in points: 358 352 if (x1, y1) == (x2, y2): continue 359 - p1 = hyper.Point.fromEuclid(x1, y1) 360 - p2 = hyper.Point.fromEuclid(x2, y2) 361 - if p1.distanceTo(p2) <= 2: 362 - line = hyper.Line.fromPoints(*p1, *p2, segment=True) 353 + p1 = hyper.Point.from_euclid(x1, y1) 354 + p2 = hyper.Point.from_euclid(x2, y2) 355 + if p1.distance_to(p2) <= 2: 356 + line = hyper.Line.from_points(*p1, *p2, segment=True) 363 357 group.draw(line, hwidth=0.2, fill='white') 364 358 for x, y in points: 365 - p = hyper.Point.fromEuclid(x, y) 366 - group.draw(hyper.Circle.fromCenterRadius(p, 0.1), 359 + p = hyper.Point.from_euclid(x, y) 360 + group.draw(hyper.Circle.from_center_radius(p, 0.1), 367 361 fill='green') 368 362 redraw(click_list) 369 363