fork download
  1. import matplotlib.pyplot as plt
  2.  
  3. # Define the size of the flag
  4. width = 300
  5. height = 200
  6.  
  7. # Create a green background
  8. flag = [[(0, 128, 0) for _ in range(width)] for _ in range(height)]
  9.  
  10. # Define the center and radius of the red circle
  11. center_x = width // 2
  12. center_y = height // 2
  13. radius = min(width, height) // 4
  14.  
  15. # Bresenham circle drawing algorithm
  16. x = 0
  17. y = radius
  18. p = 3 - 2 * radius
  19.  
  20. while x <= y:
  21. for dx, dy in [(x, y), (-x, y), (x, -y), (-x, -y), (y, x), (-y, x), (y, -x), (-y, -x)]:
  22. flag[center_y + dy][center_x + dx] = (255, 0, 0)
  23. x += 1
  24. if p < 0:
  25. p += 4 * x + 6
  26. else:
  27. y -= 1
  28. p += 4 * (x - y) + 10
  29.  
  30. # Display the flag
  31. plt.imshow(flag)
  32. plt.axis('off')
  33. plt.show()
  34.  
Success #stdin #stdout 0.7s 56788KB
stdin
Standard input is empty
stdout
Standard output is empty