import numpy as np
import cv2

canvas = np.zeros((300,300,3), dtype="uint8")

cv2.imshow('empty canvas', canvas)
green = (0,255,0)
cv2.line(canvas, (0,0), (300,300), green)
cv2.imshow('Canvas', canvas)

red = (0, 0, 255)
cv2.line(canvas, (300, 0), (0, 300), red, 3)
cv2.imshow("Canvas", canvas)

cv2.rectangle(canvas, (10, 10), (60, 60), green)
cv2.imshow("Canvas", canvas)

cv2.rectangle(canvas, (50, 200), (200, 225), red, 5)
cv2.imshow("Canvas", canvas)

blue = (255, 0, 0)
cv2.rectangle(canvas, (200, 50), (225, 125), blue, -1)
cv2.imshow("Canvas", canvas)


canvas = np.zeros((300, 300, 3), dtype = "uint8")
(centerX, centerY) = (canvas.shape[1] // 2, canvas.shape[0] // 2)
white = (255, 255, 255)

for r in range(0, 175, 25):
    cv2.circle(canvas, (centerX, centerY), r, white)

cv2.imshow("Canvas", canvas)

canvas = np.zeros((300, 300, 3), dtype = "uint8")

for i in range(0, 25):
    radius = np.random.randint(5, high = 200)
    color = np.random.randint(0, high = 256, size = (3,)).tolist()
    pt = np.random.randint(0, high = 300, size = (2,))
    cv2.circle(canvas, tuple(pt), radius, color, -1)
cv2.imshow("Canvas", canvas)


# exercici
canvas = np.zeros((300, 300,3), dtype="uint8")
for row, y in enumerate(range(0, 300, 10)):
    for col, x in enumerate(range(0, 300, 10)):
        color = (0,0,0)
        if row % 2 == col % 2:
            color = (0,0,255)
        cv2.rectangle(canvas, (x, y), (x+10, y+10), color, -1)

cv2.circle(canvas, (150,150), radius=60, color=(0,255,0), thickness=-1)
cv2.imshow('exercici1', canvas)