Guest User

curved_polygon

a guest
Apr 20th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. from graph import *
  2.  
  3. def curved_polygon(points, **polygon_opts):
  4.     _C = canvas()
  5.     coord = unpackCoord(points)
  6.     if points[0] != points[-1]:
  7.         points.append(points[0])
  8.     tk_opts = {"outline": penColor(),
  9.                "width": penSize(),
  10.                "fill": brushColor()}
  11.     for _key in ["smooth", "splinesteps"]:
  12.         if _key in polygon_opts.keys():
  13.             tk_opts[_key] = polygon_opts[_key]
  14.     plg = _C.create_polygon(*coord, tk_opts)
  15.     return plg
  16.  
  17. if __name__ == '__main__':
  18.     windowSize(800, 400)
  19.     canvasSize(800, 400)
  20.     mainWindow()
  21.     curved_polygon( [ (0, 0),
  22.                       (100, 0),
  23.                       (300, 200),
  24.                       (400, 200),
  25.                       (600, 0),
  26.                       (700, 0),
  27.                       (700, 100),
  28.                       (400, 200),
  29.                       (400, 300)
  30.                       ], smooth=True, )
  31.     run()
Advertisement
Add Comment
Please, Sign In to add comment