IMG_W, IMG_H = 320, 90 MSG = "\x4a\x6f\x79\x65\x75\x78\x20\x4e\x6f\x65\x6c\x20\x32\x30\x32\x32\x20\x54\x49\x2d\x50\x6c\x61\x6e\x65\x74\x20\x3d\x5e\x2e\x5e\x3d" from ti_graphics import drawImage, setColor, fillRect, drawString, setPixel, getPixel from ti_system import escape SCR_W, SCR_H, SCR_Y0 = 320, 210, 30 FONT_W, FONT_H = 10, 15 def fill_rect(x, y, w, h, c): setColor(c) fillRect(x, y + SCR_Y0, w, h) def draw_string(s, x, y, cf): setColor(cf) drawString(s, x, y + SCR_Y0) def set_pixel(x, y, c): setPixel(x, y + SCR_Y0, c) def get_pixel(x, y): return getPixel(x, y + SCR_Y0) from random import randint from math import cos COLOR_BACK = (0, 12, 24) fill_rect(0, 0, SCR_W, SCR_H, COLOR_BACK) COLOR_BACK_GET = get_pixel(0, 0) IMG_Y = SCR_H - IMG_H drawImage("Noel2022", 0, SCR_Y0 + IMG_Y) draw_string(MSG, (FONT_W and SCR_W - len(MSG)*FONT_W) // 2, (IMG_Y - FONT_H) // 2, (0, 11, 24)) liste_flocons = [] while(not escape()): for flocon in liste_flocons: x, y, seed, x_i = flocon[:4] oldx, oldy, oldx_i = x, y, x_i if y < SCR_H - 1: newy = y + 1 x += cos(seed / 20) / 2 tries = [(x, round(x)), (oldx, oldx_i)] for v in (x + 1, x - 1, oldx + 1, oldx - 1): v_i = round(v) if v_i >= 0 and v_i < SCR_W: tries.append((v, v_i)) for lx in tries: x, x_i = lx if x_i < 0 or x_i >= SCR_W or get_pixel(x_i, newy) == COLOR_BACK_GET: y = newy break if y == oldy: liste_flocons.remove(flocon) else: if oldx_i >=0 and oldx_i < SCR_W: set_pixel(oldx_i, oldy, COLOR_BACK) if x_i >=0 and x_i < SCR_W: set_pixel(x_i, y, (255, 255, 255)) flocon[:4] = x, y, seed + 1, x_i if not randint(0,3): x = randint(0, SCR_W - 1) liste_flocons.append([x, 0, randint(0, SCR_W), x])