Annonce

>>> Bienvenue sur codelab! >>> Première visite ? >>> quelques mots sur codelab //// une carte des membres//// (apéros) codelab


#1 2012-04-26 17:46:47 [allRGB][python] JKP - allRGB

Laure Tiblanche
membre
Date d'inscription: 2012-04-26
Messages: 152

[allRGB][python] JKP - allRGB



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")

http://jkp.antisocial.be/images/JKP-allRGB-14-25-74.jpg

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")

http://jkp.antisocial.be/images/JKP-allRGB-rand1212.jpg

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

http://jkp.antisocial.be/images/JKP-allRGB-Spiral002.jpg

Download --> http://jkp.antisocial.be/scripts/JKP-allRGB-Spiral.zip

Hors ligne

 

#2 2012-05-04 16:44:19 Re : [allRGB][python] JKP - allRGB

Laure Tiblanche
membre
Date d'inscription: 2012-04-26
Messages: 152

Re: [allRGB][python] JKP - allRGB



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")

http://jkp.antisocial.be/images/JKP-allRGBTurtle-1254.png

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

 

#3 2012-05-04 16:46:33 Re : [allRGB][python] JKP - allRGB

Laure Tiblanche
membre
Date d'inscription: 2012-04-26
Messages: 152

Re: [allRGB][python] JKP - allRGB



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")

http://jkp.antisocial.be/images/JKP-allRGBTurtle-4545.png

Download

-->>> http://jkp.antisocial.be/scripts/JKP-al … e-4545.zip

Hors ligne

 

#4 2012-05-04 16:47:39 Re : [allRGB][python] JKP - allRGB

Laure Tiblanche
membre
Date d'inscription: 2012-04-26
Messages: 152

Re: [allRGB][python] JKP - allRGB



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")

http://jkp.antisocial.be/images/JKP-allRGBTurtle-4577.png

Download

-->>> http://jkp.antisocial.be/scripts/JKP-al … e-4577.zip

Hors ligne

 

fil rss de cette discussion : rss

Pied de page des forums

Powered by FluxBB

codelab, graphisme & code : emoc / 2008-2024