updated_tree.py

Created by mty

Created on September 21, 2024

3.44 KB


# update of numworks's autumn21.py

from kandinsky import *
from time import *
from random import *

branchColor = (77,24,8)
leafColors = [(216,98,24),(255,183,52),(181,168,12),(178,51,34)]

rootAndBranchesSquares = [
(200,159,6,46), (196,156,4,49),
(193,179,4,26), (206,193,2,12),
(203,115,6,44), (209,131,2,35),
(206,159,3,13), (191,195,2,10),
(211,156,3,5), (214,152,3,5),
(217,149,3,5), (220,146,3,5),
(223,143,3,5), (241,127,3,12),
(244,126,16,3), (260,121,16,3),
(257,121,3,5), (273,116,3,5),
(254,105,3,18), (257,85,2,22),
(236,95,2,22), (185,93,3,14),
(190,72,4,3), (188,104,9,3),
(195,128,8,3), (189,125,8,3),
(177,122,14,3), (176,91,9,4),
(172,87,6,4), (211,61,4,3),
(190,56,4,3), (196,67,13,2),
(201,84,22,2), (204,95,13,2),
(155,88,17,2), (152,121,16,2),
(158,114,10,2), (149,107,10,2),
(129,117,23,2), (158,108,2,6),
(144,83,13,2), (138,78,13,2),
(146,80,2,3), (165,70,2,18),
(138,75,2,3), (188,73,2,22),
(173,65,2,22), (163,57,2,13),
(197,104,4,7), (194,53,2,22),
(209,47,2,22), (215,42,2,22),
(187,51,3,7), (184,45,3,7),
(182,40,2,7), (180,28,2,12),
(223,85,3,6), (226,85,8,2),
(236,93,9,2), (209,115,27,2),
(238,139,11,2), (236,71,9,2),
(201,107,3,21), (204,97,5,12),
(193,156,3,8), (188,153,5,8),
(177,151,11,4), (146,150,19,2),
(138,148,10,2), (123,150,17,2),
(136,146,6,2), (128,134,2,5),
(127,115,2,5), (130,139,6,2),
(135,141,2,5), (225,139,13,5) ]

leafSquares1 = [
(229,117,12,12), (200,70,12,12),
(183,132,12,8), (232,146,12,12),
(190,88,12,12), (155,90,12,12),
(172,155,12,12), (165,145,12,9),
(147,137,12,12), (108,119,12,12),
(127,103,12,12), (159,45,12,12),
(175,16,12,12), (218,44,12,12),
(234,77,12,12), (238,56,12,12),
(274,104,12,12), (211,119,10,9),
(256,161,8,8), (142,203,12,5),
(186,205,12,5), (107,207,8,2),
(245,206,8,2), (222,205,12,2)]

leafSquares2 = [
(124,125,9,9), (117,100,9,9),
(114,148,9,9), (157,157,9,9),
(221,105,9,9), (276,88,9,9),
(251,65,9,9), (190,40,9,9),
(143,119,9,9), (167,201,9,9),
(215,203,7,6), (253,202,8,6),
(245,91,9,9), (256,76,9,9),
(125,56,9,9), (169,32,9,9),
(177,63,9,9), (217,91,9,9),
(176,98,9,9), (192,76,9,9),
(130,153,9,9), (137,65,9,9),
(134,83,9,9), (153,60,9,9),
(168,117,9,9), (97,133,9,9),
(240,108,9,9), (223,126,9,9),
(192,146,9,9), (217,154,9,9),
(260,130,9,9), (262,107,9,9)]

leafSquares3 = [
(145,99,4,15), (157,73,4,15),
(179,75,4,15), (202,50,4,15),
(249,133,4,15), (291,110,4,15),
(149,152,4,15), (131,68,4,15),
(119,133,4,15), (205,199,4,15),
(236,196,2,15), (157,201,2,15),
(102,198,2,15), (268,202,3,9),
(166,122,4,15), (214,160,4,15),
(215,96,4,15), (181,195,4,15),
(213,32,4,15), (173,51,6,6),
(177,108,6,6), (170,134,6,6),
(229,93,6,6), (216,130,4,15),
(221,73,4,15), (265,87,4,15) ]

leafSquares4 = [
(245,118,8,7), (152,123,8,7),
(164,104,8,7), (280,119,8,7),
(136,132,8,7), (228,57,8,7),
(217,66,9,11), (189,114,8,7),
(186,167,8,7), (125,207,8,3),
(209,201,4,4), (238,205,4,4),
(178,205,4,4), (278,206,5,2) ]


def drawSquares(squares, color):
    for s in squares:
        fill_rect(s[0], s[1], s[2], s[3], color)


# logic starts here

# draw tree root and branches
drawSquares(rootAndBranchesSquares, branchColor)

# draw leaves
initialColor = choice(leafColors)
drawSquares(leafSquares1, initialColor)
drawSquares(leafSquares2, initialColor)
drawSquares(leafSquares3, initialColor)
drawSquares(leafSquares4, initialColor)

# now change color of the leaves
while 1:

    sleep(0.75)
    drawSquares(
        choice([leafSquares1, leafSquares2, leafSquares3, leafSquares4]),
        choice(leafColors)
    )

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.