MCPcopy Create free account
hub / github.com/CompVis/zigma / draw_pineao_curve

Function draw_pineao_curve

utils/utils_zigzag.py:305–327  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

303
304
305def draw_pineao_curve():
306 import matplotlib.pyplot as plt
307
308 def peano_curve(level, x, y, dx, dy):
309 if level == 0:
310 plt.plot([x, x + dx], [y, y + dy], color="black")
311 else:
312 dx /= 3
313 dy /= 3
314 peano_curve(level - 1, x, y, dx, dy)
315 peano_curve(level - 1, x + dx, y + dy, dx, dy)
316 peano_curve(level - 1, x + 2 * dx, y + dy, dx, dy)
317 peano_curve(level - 1, x + dx, y + 2 * dy, dx, dy)
318 peano_curve(level - 1, x, y + 2 * dy, dx, dy)
319
320 plt.figure(figsize=(6, 6))
321 peano_curve(
322 3, 0, 0, 1, 1
323 ) # Increase the first argument to increase the complexity of the curve
324 plt.gca().invert_yaxis() # Invert y axis to match the standard mathematical coordinate system
325 plt.axis("off") # Hide axes
326 plt.show()
327 plt.savefig("peano_curve.png", bbox_inches="tight")
328
329
330if __name__ == "__main__":

Callers 1

utils_zigzag.pyFile · 0.85

Calls 1

peano_curveFunction · 0.85

Tested by

no test coverage detected