[Tutor] Variations on putpixel - More Pixel manipulation - #14

D. Hartley denise.hartley at gmail.com
Wed Jun 1 00:28:48 CEST 2005


Rudy,
I have the im.getpixel incrementing at every pixel by i (in a for loop
for each pixel in wire.png), and I know incrementing the xy in the new
one goes like this:

x + 1
y + 1
x - 1
x - 1
y - 1
y - 1
x + 1
x + 1
x + 1 ... etc

First the x and then the y is incremented by 1, then that 1 is made
negative and the # of times += 1.  then, back around, then the 1 is
made positive again, and so on.

But how can I increment a changing "to_coordinate" variable in this
weird way each time while still only incrementing the
"from_coordinate" by 1 in a for loop? I keep trying to set up my
function and only being able to change one or the other at a time!

I apologize if my question seems elementary, I am still rather new at this :)

~Denise

On 5/31/05, Rudy Schockaert <rudy.schockaert at gmail.com> wrote:
> import Image # PIL
> im = Image.open(r'd:\riddle\wire.png')
> im1=Image.new(im.mode,(100,100))
> .....
>         im1.putpixel((x,yl),im.getpixel((p,0)))
> ....
> 
> Trying not to spoil all the fun
> 
> 
> On 5/31/05, D. Hartley <denise.hartley at gmail.com> wrote:
> > 
> > Hello, everyone!
> > 
> > I know you didn't expect to hear from me anymore about these pesky
> > challenges, since I started the off-tutor list about it, but I'm
> > afraid I'm stuck and cannot get a hint.
> > 
> > If I want to rearrange a long string of pixels in a different order, 
> > using "putpixel" with a certain size new image (in this case, 100x100)
> > will take the long string of pixels, fill the first line of the new
> > image, and then more or less "carriage return" to fill the next line 
> > from the left to the right.
> > 
> > Does anyone know a different way to .... put.. pixels?
> > 
> > (Again, this *is* for the python challenges, if anyone has passed this
> point).
> > 
> > Thanks, and sorry for bringing this back into the list! 
> > 
> > ~Denise
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor 
> > 
> 
> 
> 
> -- 
> "Don't you wish there were a knob on the TV to turn up the intelligence?
> There's one marked 'Brightness,' but it doesn't work." - Gallagher


More information about the Tutor mailing list