In [ ]:
from ipycanvas import Canvas

canvas = Canvas(width=200, height=200)

canvas.fill_style = '#63934e'
canvas.stroke_style = '#4e6393'
canvas.line_width = 5
canvas.fill_polygon([(20, 20), (180, 20), (100, 150)])
canvas.stroke_polygon([(20, 20), (180, 20), (100, 150)])

canvas
In [ ]:
from math import pi

import numpy as np

from ipycanvas import Canvas
In [ ]:
def polygon(canvas, x, y, radius, n_points):
    angles = (2 * pi / n_points) * np.arange(n_points)

    v_x = x + np.cos(angles) * radius
    v_y = y + np.sin(angles) * radius

    points = np.stack((v_x, v_y), axis=1)

    canvas.fill_polygon(points)
In [ ]:
background_color = '#89c64f'
polygon_color = '#c6574f'
In [ ]:
canvas = Canvas(width=500, height=500)

canvas.fill_style = background_color
canvas.fill_rect(0, 0, canvas.width, canvas.height)

canvas.fill_style = polygon_color
polygon(canvas, 250, 250, 100, 6)

canvas