#! /usr/bin/python3 # =================================================================== # draw a polygon (center coordinates) # =================================================================== import transformation_matrix as tm import coordinate_conversion as cc from draw_xy_axes import draw_xy_axes import user_interface as ui from graphics import * import numpy as np import os, sys win_width = 801 win_height = 801 # ---- polygon point array/list (center coordinates) cent_points = ( (-200,300), (100,200), (100,0), (200,-200), (-100,-200) ) # ---- create polygon point array/list (window coordinates) win_points = [] for p in cent_points: x,y = cc.center_to_win_coords(p[0],p[1],win_width,win_height) win_points.append(Point(x,y)) # ---- draw polygon win = GraphWin("Demo Polygon Point Array", win_width, win_height) win.setBackground("white") draw_xy_axes(win,True) p = Polygon(win_points) p.setWidth(1) ##p.setOutline('black') p.setOutline('red') p.setFill('red') p.draw(win) # ---- wait to continue ui.pause() win.close() print()