caract.py

Created by schraf

Created on May 14, 2026

979 Bytes


from kandinsky import *
from random import randint

WIDTH  = 320
HEIGHT = 222
TEMP_Y = HEIGHT - 18
WHITE  = get_pixel(10,10)

def extraire_pixels(char):
    fill_rect(0, TEMP_Y, 10, 18, WHITE)
    draw_string(char, 0, TEMP_Y, (randint(0, 230),) * 3, WHITE)
    offsets = []
    for dy in range(18):
        for dx in range(10):
            v = get_pixel(0 + dx, TEMP_Y + dy)
            if v != WHITE: offsets.append((dx, dy, v))
    fill_rect(0, TEMP_Y, 10, 18, WHITE)
    return offsets

x, y = -10, 0

while y < 220:
    v = 65 if randint(0,1) else 97
    char = chr(randint(v, v+25))
    offsets = extraire_pixels(char)
    for dx, dy, coul in offsets:
        tx, ty = x + dx, y + dy
        if 0 <= tx < WIDTH and 0 <= ty < HEIGHT: set_pixel(tx, ty, coul)
    x = (x + randint(6,9))
    if x > 320:
        x = x % 320 - 10
        y += randint(9,12)

for dy in range(18):
    for dx in range(10):
        set_pixel(0 + dx, TEMP_Y + dy,get_pixel(dx + 40, dy))

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.