Uploaded May 2025 | Updated November 2026, 2 hours ago
On discute de l'inversion et créer la première image de la collection "Images mathématiques"
pour vous abonner sur Ulule, c'est par là : fr.ulule.com/mickaellaunay
À suivre le code que nous avons fait. Allez aussi voir dans les commentaires qui proposent des variantes !
import math
from PIL import Image
width = 2480
height = 3508
C = width/2
R = width/2
echiquier = Image.new('RGB', (width, height), (255,255,0))
for x in range(width):
for y in range(height):
x0 = x-width/2+0.5
y0 = y-height/2+0.5
f = R**2/(x0**2+y0**2+0.000000000001)
x1 = x0*f
y1 = y0*f
cx = math.floor(x1/C)
cy = math.floor(y1/C)
color = ((cx+cy)%2)*255
echiquier.putpixel((x,y),(color,color,color))
echiquier.show()
On discute de l'inversion et créer la première image de la collection "Images mathématiques"
pour vous abonner sur Ulule, c'est par là : fr.ulule.com/mickaellaunay
À suivre le code que nous avons fait. Allez aussi voir dans les commentaires qui proposent des variantes !
import math
from PIL import Image
width = 2480
height = 3508
C = width/2
R = width/2
echiquier = Image.new('RGB', (width, height), (255,255,0))
for x in range(width):
for y in range(height):
x0 = x-width/2+0.5
y0 = y-height/2+0.5
f = R**2/(x0**2+y0**2+0.000000000001)
x1 = x0*f
y1 = y0*f
cx = math.floor(x1/C)
cy = math.floor(y1/C)
color = ((cx+cy)%2)*255
echiquier.putpixel((x,y),(color,color,color))
echiquier.show()






![Flocon de von Koch, fractales et carte n°3
On parle de fractales et on génère la troisième carte de la collection Ulule !
Le code final (encore optimisable !)
import math
from PIL import Image, ImageDraw
width = 1748
height = 1240
vonkoch = Image.new(RGB, (width,height), (255,255,255))
draw = ImageDraw.Draw(vonkoch)
def koch(A,B,n):
if (n 0):
draw.line((A,B), fill=(0,0,0), width=1)
else:
M2 = sim(A,B,math.pi/6,1/math.sqrt(3))
koch(M2,A,n-1)
koch(B,M2,n-1)
def sim(A,B,alpha,mu):
C = [B[0]-A[0],B[1]-A[1]]
D = [mu*(C[0]*math.cos(alpha)+C[1]*math.sin(alpha)),mu*(-C[0]*math.sin(alpha)+C[1]*math.cos(alpha))]
return [A[0]+D[0],A[1]+D[1]]
def flocon(A,B):
C = sim(B,A,math.pi/3,1)
koch(A,B,14)
koch(B,C,14)
koch(C,A,14)
L = 600
for i in range(3):
for j in range(3):
A0 = [1748/2+L/2+L*(i-1),height/2+L*math.sqrt(3)/6+L*2/3*math.sqrt(3)*(j-1)+L/3*math.sqrt(3)*(i-1)]
B0 = [1748/2-L/2+L*(i-1),height/2+L*math.sqrt(3)/6+L*2/3*math.sqrt(3)*(j-1)+L/3*math.sqrt(3)*(i-1)]
flocon(A0,B0)
vonkoch.show() Flocon de von Koch, fractales et carte n°3](https://i.ytimg.com/vi/vBh-S9u4utY/mqdefault.jpg)
![[17h] Ces figures sorties de nulle part, avec Robin Jamet - Myriogon #11
Cet après-midi, nous parlons dorganisation de Mathmob avec Robin Jamet : comment faire apparaître des figures étonnantes à partir de quelques règles simples.
Mathcurve : https://www.mathcurve.com/ [17h] Ces figures sorties de nulle part, avec Robin Jamet - Myriogon #11](https://i.ytimg.com/vi/vGTP4exGtMo/mqdefault.jpg)


