premier script
from PIL import Image
tableau_RGB = []
tailleR = 256
tailleG = 256
tailleB = 256
tailleT = tailleR * tailleG * tailleB
for x in range(tailleR):
for y in range(tailleG):
for z in range(tailleB):
tableau_RGB.append((x,y,z))
image = Image.new("RGB", (4096,4096), "white")
for x in xrange(image.size[0]):
for y in xrange(image.size[1]):
image.putpixel((x,y),(tableau_RGB.pop()))
image.save("RGB#14-25-74.jpg", "JPEG")
Download --> http://jkp.antisocial.be/scripts/JKP-al … compte.zip
deuxième script
from PIL import Image
import math
import random
tableau_RGB = []
tailleR = 256
tailleG = 256
tailleB = 256
tailleT = tailleR * tailleG * tailleB
for x in range(tailleR):
for y in range(tailleG):
for z in range(tailleB):
tableau_RGB.append((x,y,z))
image = Image.new("RGB", (4096,4096), "white")
for x in xrange(image.size[0]):
for y in xrange(image.size[1]):
tailleT = tailleT - 1
image.putpixel((x,y),(tableau_RGB.pop(random.randint(0,tailleT))))
image.save("JKP-allRGB-#rand1212.jpg", "JPEG")
Download --> http://jkp.antisocial.be/scripts/JKP-allRGB-Random.zip
Troisieme script
from PIL import Image
from math import sqrt
def spiral(n,tableau_RGB):
dx,dy = 1,0 # Starting increments
x,y = 0,0 # Starting location
myarray = [[None]* n for j in range(n)]
for i in xrange(n**2):
myarray[x][y] = tableau_RGB[i]
nx,ny = x+dx, y+dy
if 0<=nx<n and 0<=ny<n and myarray[nx][ny] == None:
x,y = nx,ny
else:
dx,dy = -dy,dx
x,y = x+dx, y+dy
return myarray
def printspiral(myarray):
n = range(len(myarray))
for y in n:
for x in n:
print myarray[x][y],
print
def creationimage(myarray):
n = range(len(myarray))
image = Image.new("RGB", (len(myarray),len(myarray)), "white")
for y in n:
for x in n:
image.putpixel((x,y),myarray[x][y])
image.save("RGB#Spiral#001.jpg", "JPEG")
def initRGB(n):
tableau_RGB = []
for x in range(n):
for y in range(n):
for z in range(n):
tableau_RGB.append((x,y,z))
return tableau_RGB
size = 256
sizeTotal = size * size * size
creationimage(spiral(int(sqrt(sizeTotal)),initRGB(size)))avec un code de spiral piqué sur wikipedia
Download --> http://jkp.antisocial.be/scripts/JKP-allRGB-Spiral.zip
Hors ligne
yop
from UndrawnTurtle import *
from PIL import Image
tableau_RGB = []
tailleR = 256
tailleG = 256
tailleB = 256
tailleT = tailleR * tailleG * tailleB
for x in range(tailleR):
for y in range(tailleG):
for z in range(tailleB):
tableau_RGB.append((256-x,y,256-z))
image = Image.new("RGB", (5785,5785), "white")
T = UndrawnTurtle()
T.setpos(0,0)
size = image.size[1]
for i in xrange(image.size[0]):
for j in xrange(size):
try:
image.putpixel((int(T.xcor()),int(T.ycor())),(tableau_RGB.pop()))
except:
pass
T.forward(1)
if(i % 2) == 0:
T.left(90)
T.forward(1)
#print "on tourne a gauche",i
T.left(90)
T.forward(1)
else:
T.right(90)
T.forward(1)
#print "on tourne a droite",i
T.right(90)
T.forward(1)
size = size - 1
image.save("JKP-allRGB#Turtle-1254.jpg", "JPEG")
download
http://jkp.antisocial.be/scripts/JKP-al … e-1254.zip
Dernière modification par Laure Tiblanche (2012-05-04 16:45:19)
Hors ligne
from UndrawnTurtle import *
from PIL import Image
tableau_RGB = []
tailleR = 256
tailleG = 256
tailleB = 256
tailleT = tailleR * tailleG * tailleB
for x in range(tailleR):
for y in range(tailleG):
for z in range(tailleB):
tableau_RGB.append((x,y,z))
image = Image.new("RGB", (4096,4096), "white")
T = UndrawnTurtle()
T.setpos(0,0)
for i in xrange(image.size[0]):
for j in xrange(image.size[1]):
#print int(T.xcor()),int(T.ycor())
image.putpixel((int(T.xcor()),int(T.ycor())),(tableau_RGB.pop()))
T.forward(1)
if(i % 2) == 0:
T.left(90)
T.forward(1)
#print "on tourne a gauche",i
T.left(90)
T.forward(1)
else:
T.right(90)
T.forward(1)
#print "on tourne a droite",i
T.right(90)
T.forward(1)
image.save("JKP-allRGB#Turtle-4545.jpg", "JPEG")
Download
-->>> http://jkp.antisocial.be/scripts/JKP-al … e-4545.zip
Hors ligne
from UndrawnTurtle import *
from PIL import Image
tableau_RGB = []
tailleR = 256
tailleG = 256
tailleB = 256
tailleT = tailleR * tailleG * tailleB
for x in range(tailleR):
for y in range(tailleG):
for z in range(tailleB):
tableau_RGB.append((y,x,z))
image = Image.new("RGB", (4096,4096), "white")
T = UndrawnTurtle()
T.setpos(0,0)
#j = 0
size = 4095
for j in range(size):
T.setpos(0,j)
for i in range(size):
T.forward(1)
image.putpixel((int(T.xcor()),int(T.ycor())),(tableau_RGB.pop()))
#image.putpixel((int(T.xcor()),int(T.ycor())),1)
# print int(T.xcor()),int(T.ycor())
T.left(90)
for i in range(size):
T.forward(1)
image.putpixel((int(T.xcor()),int(T.ycor())),(tableau_RGB.pop()))
#print int(T.xcor()),int(T.ycor())
size = size - 1
T.right(90)
image.save("JKP-allRGB#Turtle-4577.jpg", "JPEG")
Download
-->>> http://jkp.antisocial.be/scripts/JKP-al … e-4577.zip
Hors ligne
Pages: 1