“Lunar Fireworks” en Python. Développé par Ilyas R. à l’occasion du DM MX11 “Un feu d’artifice en python” édition 2023-2024. #nsi_xyz
from kandinsky import fill_rect, set_pixel from random import randint moon_c = {'~': (255, 255, 255), '`': (252, 252, 252), 'A': (1, 1, 1), 'j': (98, 98, 98), '2': (152, 152, 152), 'q': (117, 117, 117), '3': (154, 154, 154), 'z': (142, 142, 142), '5': (159, 159, 159), 'y': (141, 141, 141), '1': (148, 148, 148), '?': (249, 249, 249), 'P': (43, 43, 43), 'V': (61, 61, 61), 'X': (64, 64, 64), 'c': (78, 78, 78), 'r': (122, 122, 122), 'u': (130, 130, 130), 'l': (105, 105, 105), '7': (165, 165, 165), 'x': (139, 139, 139), '8': (167, 167, 167), '/': (247, 247, 247), 'a': (73, 73, 73), 'Y': (67, 67, 67), 'f': (88, 88, 88), 'v': (131, 131, 131), 'h': (93, 93, 93), 'i': (96, 96, 96), 'k': (102, 102, 102), '@': (177, 177, 177), 'B': (3, 3, 3), 'Q': (46, 46, 46), 'Z': (72, 72, 72), '9': (171, 171, 171), 's': (124, 124, 124), 'n': (111, 111, 111), 'b': (76, 76, 76), 'g': (91, 91, 91), 't': (126, 126, 126), 'd': (83, 83, 83), 'e': (86, 86, 86), '&': (190, 190, 190), 'o': (113, 113, 113), '0': (147, 147, 147), 'w': (135, 135, 135), '>': (244, 244, 244), 'O': (40, 40, 40), 'm': (106, 106, 106), '6': (163, 163, 163), 'p': (115, 115, 115), 'U': (57, 57, 57), '4': (156, 156, 156), 'W': (63, 63, 63), 'E': (13, 13, 13), 'D': (9, 9, 9), 'C': (8, 8, 8), '!': (174, 174, 174), '#': (180, 180, 180)} moon_i = ['~``~``~~~~~~AAAAAAAA~~~~`~`~`~~~', '~~~~~~~~~AAAj2q3z5y1AAA~~`~~~?`~', '~~~?~~~`APVXcrul7zyrx8zA~~~``~~`', '/~~~~`AAaYfvhhliikjvy2@yBA``~~/~', '~`~?`AQZZcu91vsxjrxxlfjn3zA~~`~?', '?~?~AQaaXbvgtdetbbbhujx29&xA~~`~', '~?~AkdadaZcYaVZbZYYaqyz81x@oA`~~', '~`~AauaagdYZYZedZXban0075hnsA~`~', '~~AneaXZebafZbndZZlnqnxz2lw0sA`~', '>AOfuZZZZZffblv7qZZblfxlm260zpB`', '~AUdsZbiaZmcXc483ceZez5vg15z0vA`', '~AocacZcYabYYZbf2qaZxgcik41r1sA~', 'AszbwtZVeZjaXYYegmaaeWYfv0xzwtsB', 'AgweZbhdZbZaafhfdcefXblhkyxcazwB', 'AfercYtpalcibYghhXbfXYhgizxaXctE', 'AtjcvvrcZZaaamifoiXZaYaXZxybelsD', 'AsuduvbXaYfYZghZhmablbYYYc0vfvpB', 'AoebuZXZlbYYabYZXcnpoZYZYawuutuC', 'AuvbtcXccZaalYZYXawocZZZZXbvymrA', 'AqvxxuxysaXacZVZYdukdYZubYYafrtA', '~As1uw0weZajYYaYbvzihZdweWYYkrA~', '~Au9vx0zwtbYZf0eu013favxifbgxvA~', '`Ap48yuj00dan10z2301cZx1yhex3pA~', '~~A12vki5zz5gy0!!1yfVb02kukzsA~`', '`~~Auxwx40!@047!246udu8ykxzuA`~~', '~~`Bmxsxo20z7#92610z30wzy5unA~~`', '~`~`Akzvx02039@6640z1ziv8wmA`~`~', '~~~~~Alu10w5xv@720080wiluyA~~~`~', '~~`~``BAr6yvyvz5x110ny0pAA~~~~~?', '~`~~~~~~Alvou0021zwplhqA~~`~`~~~', '~?~``~`~~AAAturuxtjqAAA~~~~~~~?~', '~~~`~~`~~`~~ABBAABAA~~~~~~~~~`~~'] fw_y_c = {'~': (255, 255, 255), '$': (254, 200, 91), 's': (207, 144, 17), 'h': (157, 112, 13), 'X': (111, 78, 10), 'P': (70, 51, 10), 'H': (35, 25, 5)} fw_y_i = ['~~~~~~~~~~$~~~~~~~~~', '~~~~~~~$~~$~~~~$~~~~', '~~~~~~~s~~s~~~s~~~~~', '~~~~~$~~h~h~~Xh~~~~~', '~~~~~~s~~PX~HP~~~$~~', '~~$$~X~h~HP~H~~~s~~~', '~~~s~~P~X~H~~~~Xh~~~', '~~~~h~H~P~H~HHP~~~~~', '~~~~~X~~HP~XH~~~~~$~', '~~~~~~P~~X~HHHPXhs~~', '~~~hXP~PH~HXH~~~h~~~', '~$s~~~X~~H~H~PXHPXs~', '$~~~~h~~~P~~P~~h~~~$', '~~~~s~~HX~H~X~P~s~~~', '~~~$~~Hh~~P~h~~P~$~~', '~~~~~P~s~~X~~h~~~~~~', '~~~~~~$~~~h~~~s~~~~~', '~~~~~~~~~~s~~~$~~~~~', '~~~~~~~~~~$~~~~~~~~~'] palestine_c = {'f': (206, 17, 39), 'A': (0, 0, 0), '~': (239, 239, 239), 'V': (0, 122, 61)} palestine_i = ['fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'ffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'fffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'ffffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'fffffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'ffffffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'fffffffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'ffffffff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', 'fffffffff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', 'ffffffffff~~~~~~~~~~~~~~~~~~~~~~~~~~~~', 'fffffffffff~~~~~~~~~~~~~~~~~~~~~~~~~~~', 'ffffffffff~~~~~~~~~~~~~~~~~~~~~~~~~~~~', 'fffffffff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', 'ffffffff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', 'fffffffVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', 'ffffffVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', 'fffffVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', 'ffffVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', 'fffVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', 'ffVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV', 'fVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'] nuit_c = {'M': (1, 10, 96), 'K': (0, 7, 84), 'L': (1, 8, 85), 'O': (0, 14, 106), 'P': (0, 15, 111), 'N': (0, 11, 98), 'J': (0, 5, 78), 'I': (1, 3, 71), 'Q': (1, 17, 122), 'H': (0, 1, 64), 'R': (1, 20, 128)} nuit_i = ['MKKLKKLMLMOPPONLNNNLMMMLLLMNOONOONONLLMO', 'MKJIJLMMMOPQPNNMNNNMNNLLLLMONMMMMLMMMLNO', 'LLJHILMMNPQQONONMNNNNNLLLMMONMLLKJKLLLNO', 'LLJJKMNNOPQOOOPONNNOPOMNOOONMLLJKKLKLLLN', 'MKJKLNONOQPNNNOOOOONPPPPPONNNLKJKKLKLLMO', 'MKKLNNONNPONNLMOPPOPPPPQQONNNMLKKKKLLLMN', 'KKLMMNONMMOONMNOPOOPOPQRQONNNMMLLLMMMLLM', 'JLKLLMNMMMOPONOOOOOPOOQPPONNNMNNNNMNMLLM', 'IJJKLLLMNNOQPOOPPOOOOOONNNNNMNOOOONOOMML', 'IJKLLMNNNNPQPOOOQOOPOOONNONLMNPPOONNONLK', 'KKLMMNONMMNPOOPOOOOONOONMNMLMNPQPONOONML', 'LLLMNOONLKLNOOPONOONMNNNNMMLLMOPPOOPOONM', 'MLLNPQOLLMMLMNNONNMMNNMNNMMMMNNMNOPQOOOL', 'NLKMOPNLMLKKKLLMMMLMNMLMMNMMMMMLMNOONNMK', 'ONMMMNNMLKIJKKJKKLMMNMKLMNNMMMLLLMNNLMLK', 'PONNNNOMLKJIHIJKKLLMMLKLNNNNOMKKKLMONLLL', 'OOONONMLLKJIHIKKKLLLLLLMNNNOOMKKLLLNOMMM', 'OOOPPOLLLKIHIJKJJKLMLMNMNMMNNLKLLMLLMMNN', 'NMOPQPMLKIIHJKLKJKKKKLMMLLLLMLKLMNNOONNN', 'ONNOPONMKJJIJKKLLLKKLNMMLLLLMLKMMNNOONNN', 'PPNNNMNMLKKJJJJKKKKLMMMNMNMMMLKMMMNNNNOO', 'OPONMLNNLJJIJKJKKKKKLNNNMMMMLKKMONNOOOON', 'NNNNMLLMLKKKLLKKLKKKMNNMLKLMLKKLNMMNOONM', 'NNNNMLKKLMLLMMLKKKKKNONLKLLLLLKLLMLLNOMM', 'LMNMLKJLMMLKKLLMMLLLNMMMMMLLMNMMMMLLLMNO', 'NNNOLJLMNMLIJKLMMLLLMLNOOOMLMNNNMMMMMMNO', 'OOQONLMNOOLIIKKLLKKMNNNOPOMLKMNOMMNNNNNN'] fw_m_c = {'~': (255, 255, 255), '[': (255, 160, 222), '0': (201, 78, 158), 'n': (156, 54, 119), 'S': (71, 28, 55), 'c': (109, 44, 86), 'J': (35, 15, 26)} fw_m_i = ['~~~~~~~~~~[~~~~~~~~~', '~~~~~~~[~~[~~~~[~~~~', '~~~~~~~0~~0~~~0~~~~~', '~~~~~[~~n~n~~nn~~~~~', '~~~~~~0~~Sc~JS~~~[~~', '~~[[~n~n~JS~J~~~0~~~', '~~~0~~c~c~J~~~~cn~~~', '~~~~n~J~S~J~JJS~~~~~', '~~~~~c~~JS~cJ~~~~~[~', '~~~~~~S~~c~JJJScn0~~', '~~~ncS~SJ~JcJ~~~n~~~', '~[0~~~S~~J~J~JcJSc0~', '[~~~~n~~~S~~J~~n~~~[', '~~~~0~~Jc~J~c~S~0~~~', '~~~[~~Jn~~S~n~~S~[~~', '~~~~~S~0~~c~~n~~~~~~', '~~~~~~[~~~n~~~0~~~~~', '~~~~~~~~~~0~~~[~~~~~', '~~~~~~~~~~[~~~~~~~~~'] fw_p_c = {'~': (255, 255, 255), '*': (254, 91, 235), 'w': (207, 17, 185), 'k': (157, 13, 136), 'a': (111, 10, 99), 'R': (70, 10, 62), 'I': (35, 5, 31)} fw_p_i = ['~~~~~~~~~~*~~~~~~~~~', '~~~~~~~*~~*~~~~*~~~~', '~~~~~~~w~~w~~~w~~~~~', '~~~~~*~~k~k~~ak~~~~~', '~~~~~~w~~Ra~IR~~~*~~', '~~**~a~k~IR~I~~~w~~~', '~~~w~~R~a~I~~~~ak~~~', '~~~~k~I~R~I~IIR~~~~~', '~~~~~a~~IR~aI~~~~~*~', '~~~~~~R~~a~IIIRakw~~', '~~~kaR~RI~IaI~~~k~~~', '~*w~~~a~~I~I~RaIRaw~', '*~~~~k~~~R~~R~~k~~~*', '~~~~w~~Ia~I~a~R~w~~~', '~~~*~~Ik~~R~k~~R~*~~', '~~~~~R~w~~a~~k~~~~~~', '~~~~~~*~~~k~~~w~~~~~', '~~~~~~~~~~w~~~*~~~~~', '~~~~~~~~~~*~~~~~~~~~'] fw_g_c = {'~': (255, 255, 255), '?': (242, 255, 248), '$': (155, 216, 172), '#': (156, 215, 171), 'q': (88, 160, 110), 'r': (89, 162, 109), '/': (240, 255, 246), 'g': (68, 123, 83), 'f': (56, 130, 79), 'W': (38, 93, 53), 'O': (25, 60, 36), 'F': (0, 42, 8), '<': (230, 255, 241), '8': (116, 239, 149), '7': (109, 243, 146), 'H': (13, 31, 19), 'P': (33, 56, 40), 'G': (10, 33, 15), '`': (251, 255, 253), 'X': (50, 86, 60), 'N': (19, 64, 31), 'M': (6, 72, 26), 'S': (8, 109, 39), 'a': (12, 157, 52), 'n': (57, 182, 91), 'U': (23, 102, 45), '@': (140, 224, 164), 'p': (77, 169, 102), 'L': (0, 75, 19), ',': (217, 255, 234)} fw_g_i = ['~~~~~~~~~?$~?~~~~~~~', '~~~~~?~#??#~??~#?~~~', '~~~~~?~q~~r~/?r~~~~~', '~~~?~#~?g~f~~Wg~~~~~', '~~~~~?r~~OW~FO~~~#~~', '~<87~W~g~HO~H~~~r~~~', '~/~r~~P~W<G~~~~Wg~~~', '~~~~g~G~O/H~GGO?`~~~', '~~~~~X~~GN<XG`~~~?#~', '~~~~~~P~~X/HGFMSan~~', '~~~fUM~PH/FWG`~?g~~~', '~@p~~~X<~H~H/OWFLUp~', '@~~~~g?~~P~~P~~g??~@', '~~~~r~~GX<G/X~O~q~/~', '~~~#~~Gg?`P~g~~N~#?~', '~~~`?N~r/`X~~g~~~~~~', '~~~~~?#,??g~~?r~~~~~', '~~~~~~~~~?r~/?#~~~~~', '~~~~~~~~~?#~?~~~~~~~'] fw_r_c = {'~': (255, 255, 255), '`': (255, 249, 250), 'z': (183, 121, 124), '>': (255, 236, 239), '<': (255, 233, 236), 'b': (124, 52, 56), '?': (255, 247, 248), 'U': (92, 41, 40), 'P': (80, 24, 25), '/': (255, 241, 243), 'K': (53, 17, 17), 'F': (46, 0, 0), '0': (226, 103, 106), 'J': (45, 19, 18), 'E': (35, 4, 2), 'L': (76, 8, 9), 'Q': (113, 10, 13), 'V': (157, 13, 13), 'c': (161, 37, 39), 'G': (52, 0, 0), 'H': (63, 0, 0), '.': (255, 226, 230)} fw_r_i = ['~~~~~~~~~`z>`~~~~~~~', '~~~~~`>z``z>``>z`~~~', '~~~~~`<b?`b<?`b<?~~~', '~~~`>z``U<U<>PU>`~~~', '~~~~~`b</KP/FK``>z`~', '~/00<P<U?FJ?F`~?b<`~', '~?<b?~K?P/F`~`/PU>`~', '~~~`U>F`K?F`FFK`~~~~', '~~~`?P``EK/PF`~~~`z<', '~~~~~`J?/P?FFFLQVc/~', '~`>VPL/KF?GPF`~`U>`~', '<zb<?`P/`E`F?KPHLPb.', 'z>``>U`~`K~~K/>U``>z', '~~~?b<?FP/F`P/K/c<?~', '~`>z``HV`~K/U>/K<z`~', '~~~~`K<b?`P><U`~~~~~', '~~~~~`z>``U>``b<?~~~', '~~~~~~~~~`b<?`z>`~~~', '~~~~~~~~~`z>`~~~~~~~'] def trace_nw(clr, img, x_pos, y_pos, size): img = [list(i) for i in img] for i in range(len(img)): for j in range(len(img[i])): if sum(clr[img[i][j]]) < 240*3: for k in range(size): for o in range(size): set_pixel(x_pos+j*size+o, y_pos+i*size+k, clr[img[i][j]]) trace_nw(nuit_c, nuit_i, 0, 0, 9) for i in range(42): set_pixel(randint(0, 320), randint(0, 222), (255,)*3) trace_nw(moon_c, moon_i, 64, 126, 6) trace_nw(palestine_c, palestine_i, 230, 130, 1) fill_rect(229, 128, 1, 50, (255,)*3) trace_nw(fw_y_c, fw_y_i, 20, 40, 3) trace_nw(fw_p_c, fw_p_i, 40, 60, 4) trace_nw(fw_m_c, fw_m_i, 200, 5, 2) trace_nw(fw_g_c, fw_g_i, 70, -20, 2) trace_nw(fw_y_c, fw_y_i, 150, 20, 4) trace_nw(fw_r_c, fw_r_i, 260, 60, 4) trace_nw(fw_g_c, fw_g_i, -10, 130, 2)