colormtx.py

Created by ews31415

Created on October 18, 2021

476 Bytes

This script generates a color matrix of random integers 1 through 9, each entry its own colors. Numbers and colors can repeat.


from math import *
from random import *
from kandinsky import *

# 2020-08-25 EWS

# color matrices
# red
mr=[0,21,0,75,255,255,101,255,255]
# green
mg=[158,96,0,0,0,0,67,127,223]
# blue
mb=[96,189,128,130,0,127,33,39,0]

# set up matrix
mat=[[0,0,0],[0,0,0],[0,0,0]]

# random numbers
for r in range(3):
  for c in range(3):
    mat[r][c]=randint(1,9)
    x=80+80*c
    y=60+60*r
    s=mat[r][c]
    draw_string(str(s),x,y,color(mr[s-1],mg[s-1],mb[s-1]))