Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Image
- img = Image.new( 'RGB', ( 100, 100 ) )
- wire = Image.open( 'wire.png', 'r' )
- xmin, xmax = 0, 99
- ymin, ymax = 0, 99
- pos = [ 0, 0 ]
- place = 0
- output = False
- while not ( xmax - 1 == xmin or ymax - 1 == ymin ):
- for x in range( xmin, xmax + 1 ):
- if output: print "x ", pos[0], " y ", pos[1]
- pos[0] = x
- place += 1
- img.putpixel( pos, wire.getpixel( ( place, 0) ) )
- ymin += 1
- for y in range( ymin, ymax + 1 ):
- if output: print "x ", pos[0], " y ", pos[1]
- pos[1] = y
- place += 1
- img.putpixel( pos, wire.getpixel( ( place, 0) ) )
- xmax -= 1
- for x in range( xmax, xmin - 1, -1 ):
- if output: print "x ", pos[0], " y ", pos[1]
- pos[0] = x
- place += 1
- img.putpixel( pos, wire.getpixel( ( place, 0) ) )
- ymax -= 1
- for y in range( ymax, ymin - 1, -1 ):
- if output: print "x ", pos[0], " y ", pos[1]
- pos[1] = y
- place += 1
- img.putpixel( pos, wire.getpixel( ( place, 0) ) )
- xmin += 1
- img.save( "spiral.png" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement