#!/usr/bin/env python3

import math
import random

import pygame as pg

white  = pg.Color('white')
black  = pg.Color('black')
yellow = pg.Color('yellow')
pink   = pg.Color('pink')

# ----------------------------------------------------------------------

def display(genf):
    pg.init()

    width = 1000
    height = 862

    window = pg.display.set_mode((width, height))
    clock = pg.time.Clock()

    done = False
    restart = True
    while not done:
        for ev in pg.event.get():
            if ev.type == pg.QUIT: done = True
            if ev.type == pg.KEYDOWN:
                if ev.key == pg.K_ESCAPE: done = True
                elif ev.key == pg.K_RETURN: restart = True

        if restart:
            restart = False
            p1 = (random.randint(10, width - 10), random.randint(10, height - 10))
            p2 = (random.randint(10, width - 10), random.randint(10, height - 10))
            p3 = (random.randint(10, width - 10), random.randint(10, height - 10))
            window.fill(black)
            pg.draw.line(window, white, p1, p2)
            pg.draw.line(window, white, p1, p3)
            pg.draw.line(window, white, p2, p3)
            pg.display.flip()

        for _ in range(10):
            # generate 10 more points and fill them in
            pt = genf(p1, p2, p3)
            pt = (round(pt[0]), round(pt[1]))
            pg.draw.circle(window, yellow, pt, 2)

        clock.tick(60)
        pg.display.flip()

    pg.quit()
