pi_nou__le_lapin.py

Created by arthurmichel-scolaire

Created on January 11, 2026

1.75 KB

“π-nou le Lapin” est une création graphique réalisée uniquement à partir de cercles, disques et arcs de cercle. Ce lapin mignon illustre comment les formes géométriques les plus simples peuvent donner naissance à un dessin expressif et attachant.


from kandinsky import *
from math import sqrt,cos,sin,pi

# === COULEURS ===
BLANC=(255,255,255)
NOIR=(0,0,0)
ROSE=(255,182,193)
ROSE_F=(255,100,140)
CIEL=(135,210,250)
HERBE=(100,190,80)
JAUNE=(255,230,80)

# === FONCTIONS ===
def disque(cx,cy,r,c):
  for y in range(max(0,int(cy-r)),min(222,int(cy+r+1))):
    dx=int(sqrt(max(0,r*r-(y-cy)**2)))
    for x in range(max(0,int(cx-dx)),min(320,int(cx+dx+1))):
      set_pixel(x,y,c)

def cercle(cx,cy,r,c,e=2):
  for i in range(360):
    a=i*pi/180
    for j in range(e):
      x=int(cx+(r-j)*cos(a))
      y=int(cy+(r-j)*sin(a))
      if 0<=x<320 and 0<=y<222:
        set_pixel(x,y,c)

def arc(cx,cy,r,c,d1,d2,e=2):
  for i in range(d1,d2):
    a=i*pi/180
    for j in range(e):
      x=int(cx+(r-j)*cos(a))
      y=int(cy+(r-j)*sin(a))
      if 0<=x<320 and 0<=y<222:
        set_pixel(x,y,c)

# === SCENE ===
fill_rect(0,0,320,222,CIEL)

# Soleil
disque(285,28,24,JAUNE)
disque(285,28,18,(255,250,150))

# Herbe
for i in range(14):
  disque(5+i*24,218,20,HERBE)

# === LAPIN ===

# Oreilles (cercles empiles)
for i in range(9):
  disque(118,5+i*10,14,BLANC)
  disque(202,5+i*10,14,BLANC)
for i in range(7):
  disque(118,10+i*10,6,ROSE)
  disque(202,10+i*10,6,ROSE)

# Tete
disque(160,105,45,BLANC)
disque(160,130,30,BLANC)

# Joues roses
disque(130,125,10,ROSE)
disque(190,125,10,ROSE)

# Yeux
disque(140,92,13,BLANC)
disque(180,92,13,BLANC)
cercle(140,92,13,NOIR,2)
cercle(180,92,13,NOIR,2)
disque(143,90,6,NOIR)
disque(183,90,6,NOIR)
disque(140,87,3,BLANC)
disque(180,87,3,BLANC)

# Nez
disque(160,112,7,ROSE_F)

# Bouche (arcs)
arc(152,122,9,NOIR,15,90,2)
arc(168,122,9,NOIR,90,165,2)

# Corps
disque(160,175,35,BLANC)

# Pattes
disque(130,200,14,BLANC)
disque(190,200,14,BLANC)

# Queue
disque(160,205,10,BLANC)

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.