fork download
  1. import cairo
  2. import math
  3.  
  4. WIDTH, HEIGHT = 800, 400
  5. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
  6. context = cairo.Context(surface)
  7.  
  8. context.rectangle(0, 0, WIDTH, HEIGHT)
  9. context.set_source_rgb(0.53, 0.81, 0.98)
  10. context.fill()
  11.  
  12. context.set_source_rgb(0.6, 0.6, 0.6)
  13. context.move_to(100, 200)
  14. context.curve_to(200, 100, 600, 100, 700, 200)
  15. context.curve_to(600, 300, 200, 300, 100, 200)
  16. context.fill_preserve()
  17. context.set_source_rgb(0, 0, 0)
  18. context.stroke()
  19.  
  20. context.set_source_rgb(0.5, 0.5, 0.5)
  21. context.move_to(700, 200)
  22. context.line_to(750, 150)
  23. context.line_to(750, 250)
  24. context.close_path()
  25. context.fill_preserve()
  26. context.stroke()
  27.  
  28. context.set_source_rgb(0.5, 0.5, 0.5)
  29. context.move_to(730, 200)
  30. context.line_to(780, 170)
  31. context.line_to(780, 230)
  32. context.close_path()
  33. context.fill_preserve()
  34. context.stroke()
  35.  
  36. context.move_to(350, 140)
  37. context.line_to(400, 90)
  38. context.line_to(450, 140)
  39. context.close_path()
  40. context.fill_preserve()
  41. context.stroke()
  42.  
  43. context.move_to(350, 250)
  44. context.line_to(400, 300)
  45. context.line_to(450, 250)
  46. context.close_path()
  47. context.fill_preserve()
  48. context.stroke()
  49.  
  50. context.set_source_rgb(0, 0, 0)
  51. context.arc(180, 180, 15, 0, 2 * math.pi)
  52. context.fill()
  53.  
  54. context.set_source_rgb(1, 1, 1)
  55. context.arc(180, 180, 5, 0, 2 * math.pi)
  56. context.fill()
  57.  
  58. context.set_source_rgb(0, 0, 0)
  59. for i in range(5):
  60. context.move_to(240 + i * 10, 210 + i * 5)
  61. context.line_to(260 + i * 10, 210 + i * 5)
  62. context.stroke()
  63.  
  64. context.set_source_rgb(0, 0, 0)
  65. context.arc(170, 200, 30, math.pi / 8, 7 * math.pi / 8)
  66. context.stroke()
  67.  
  68. # surface.write_to_png("shark.png")
  69. # print("saved as shark.png.")
Success #stdin #stdout 0.03s 13376KB
stdin
Standard input is empty
stdout
Standard output is empty