Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def construit_carre(x,y,s, couleur):
- carre = '<rect '
- carre += 'x="'+str(x)+'" '
- carre += 'y="'+str(y)+'" '
- carre += 'width="'+str(s)+'" '
- carre += 'height="'+str(s)+'" '
- carre += 'style="stroke:#000000;stroke-width:4;fill:'+couleur_hexa_string(*couleur)+'"/>'
- return carre
- def couleur_hexa_string(r,g,b):
- hexa = "#"
- hexa_r = nombre_hexa_string(r)
- hexa += "0"*(2-len(hexa_r)) + hexa_r
- hexa_g = nombre_hexa_string(g)
- hexa += "0"*(2-len(hexa_g)) + hexa_g
- hexa_b = nombre_hexa_string(b)
- hexa += "0"*(2-len(hexa_b)) + hexa_b
- return hexa
- def nombre_hexa_string(nombre):
- if nombre < 10:
- return str(nombre)
- if nombre < 16:
- return chr(65 + nombre - 10)
- i = 0
- while 16**(i+1) < nombre:
- i += 1
- quotient = nombre//16**i
- reste = nombre - 16**i*quotient
- return nombre_hexa_string(quotient)+nombre_hexa_string(reste)
- print('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="600" height="600">')
- for x in range(5, 500, 15):
- cx = round(255 -(x/500)*255)
- for y in range(5, 500, 15):
- cy = round(255 -(y/500)*255)
- # if cx < cy:
- # print(construit_carre(x,y,10, (cx,cy,0)))
- # if cy < cx:
- # print(construit_carre(x,y,10, (cx,cy,0)))
- # if cy > cx - 150 and cx > cy - 150:
- # print(construit_carre(x,y,10, (cx,cy,0)))
- print('</svg>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement