deadoralive.py

Created by schraf

Created on April 07, 2023

957 Bytes

Enoncé de l’exercice

Visitez ma chaine YouTube

from kandinsky import *
from random import *
from turtle import *

BL, WH = (0, 0, 0), (255,) * 3      # Noir et Blanc

def dot(x, y, c, fg, t, a, b):    # Transfo d'un caractère en rectangles
  draw_string(c, 0, 0, BL, WH)    # On affiche le caractere
  for v in range(18):      # On parcourt les pixels de ce caractère
    for u in range(9):
      if get_pixel(u, v)[0] < 248:  # Si ce n'est pas du blanc
        # rectangle avec effets de décalage 'a' et/ou 'b'
        fill_rect(x + u * t, y + v * t, t - a, t - b, fg)  

def aff(txt, x, y, t, a=1, b=1):
  for i, c in enumerate(txt):    # On parcourt les lettres du mot
    dot(x + i * t * 9, y, c, BL, t, a, b)      # ombre du caractere en noir
    dot(x + i * t * 9 - 3, y, c, WH, t, a, b)    # texte en blanc

def remplir(h):       # fond degradé radial
  for l in range(h):
    for c in range(320):
     set_pixel(c, l, (150,) * 3 if 140000 * random() < l ** 2 + c ** 2 else (90,) * 3)

remplir(222)
aff("WANTED", 28, 15, 5)
aff("NUMWORKS", 52, 100, 3, b=-5)    # effet texte vertical
aff("DEAD OR ALIVE", 45, 160, 2, a=4)    # effet horizontal
remplir(18)
hideturtle()
pensize(7)
for _ in range(20):     # les trous
  color(WH)
  x, y = randint(-160, 160), randint(-110, 110)
  penup(); goto(x, y);pendown()  # point en blanc
  goto(x, y)
  color(BL)     # et en noir avec léger décalage
  penup(); goto(x - 2, y - 2); pendown()
  goto(x - 2, y - 2)


from kandinsky import *
from random import *
from turtle import *

BL, WH = (0, 0, 0), (255,) * 3

def dot(x, y, c, fg, t, a, b):
  draw_string(c, 0, 0, BL, WH)
  for v in range(18):
    for u in range(9):
      if get_pixel(u, v)[0] < 248: fill_rect(x + u * t, y + v * t, t - a, t - b, fg)

def aff(txt, x, y, t, a=1, b=1):
  for i, c in enumerate(txt):
    dot(x + i * t * 9, y, c, BL, t, a, b)
    dot(x + i * t * 9 - 3, y, c, WH, t, a, b)

def remplir(h):
  for l in range(h):
    for c in range(320):
     set_pixel(c, l, (150,) * 3 if 140000 * random() < l ** 2 + c ** 2 else (90,) * 3)

remplir(222)
aff("WANTED", 28, 15, 5)
aff("NUMWORKS", 52, 100, 3, b=-5)
aff("DEAD OR ALIVE", 45, 160, 2, a=4)
remplir(18)
hideturtle()
pensize(7)
for _ in range(20):
  color(WH)
  x, y = randint(-160, 160), randint(-110, 110)
  penup(); goto(x, y);pendown()
  goto(x, y)
  color(BL)
  penup(); goto(x - 2, y - 2); pendown()
  goto(x - 2, y - 2)

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.