from math import * from kandinsky import * rouge=color(255,25,0) jaune=color(255,215,0) vert=color(0,128,0) blanc=color(255,255,255) rose=color(199,21,133) marron=color(110,80,60) def fillEllipsis(centerI, centerJ, a, b, theta, R, color): a2 = a*a b2 = b*b for i in range(centerI-3*R,centerI+3*R): for j in range(centerJ-3*R,centerJ+3*R): deltaI = i-centerI deltaJ = j-centerJ x = cos(theta)*deltaI + sin(theta)*deltaJ y = sin(theta)*deltaI - cos(theta)*deltaJ if (x*x/a2+y*y/b2 <= R): set_pixel(i, j, color) #Cadeau rose et jaune fillEllipsis(155,115, 2, 5, 4, 3,jaune) fillEllipsis(145,115, 5, 2, 4, 3,jaune) fill_rect(120,120,60,60,rose) fill_rect(120,147,60,5,jaune) fill_rect(147,120,5,60,jaune) #Cadeau rouge et marron fillEllipsis(77,160, 2, 5, 4, 3,marron) fillEllipsis(67,160, 5, 2, 4, 3,marron) fill_rect(50,165,60,60,rouge) fill_rect(50,200,60,5,marron) fill_rect(70,165,5,60,marron) #Cadeau vert et rouge fillEllipsis(233,135, 2, 5, 4, 3,rouge) fillEllipsis(223,135, 5, 2, 4, 3,rouge) fill_rect(200,140,60,60,vert) fill_rect(200,168,60,5,rouge) fill_rect(225,140,5,60,rouge) def fill_triangle(a, b, c, col, right): h = abs(b[1]-a[1]) for i in range(0, h): w = (int)(abs(b[0]-c[0])*(i/h)) if right: if a[1] < b[1]: fill_rect(a[0]-w,a[1]+i, abs(w)+1, 1, col) else: fill_rect(a[0]-w,a[1]-i, abs(w)+1, 1, col) else: if a[1] < b[1]: fill_rect(a[0],a[1]+i, abs(w)+1, 1, col) else: fill_rect(a[0],a[1]-i, abs(w)+1, 1, col) return #sapin fill_rect(0,145,30,120,marron) fill_triangle((0,0),(0,50),(57,53),vert,False) fill_triangle((0,50),(0,100),(57,53),vert,False) fill_triangle((0,100),(0,150),(57,53),vert,False) #boules de noël fillEllipsis(51,50, 4, 4, 4, 3,rouge) fillEllipsis(51,100, 4, 4, 4, 3,jaune) fillEllipsis(51,148,4,4,4,3,rose)