fork download
  1. import Image, ImageDraw, sys
  2.  
  3. dimensions = (400, 350)
  4. img = Image.new("RGB", dimensions)
  5.  
  6. draw = ImageDraw.Draw(img)
  7. num =64
  8.  
  9. i = num
  10. while (i>0) :
  11. draw.line((i*img.size[0]/num, 0, img.size[0], i*img.size[1]/num), (0, 255-i, 0))
  12. draw.line(((num-i)*img.size[0]/num, img.size[1], img.size[0], i*img.size[1]/num), (0, 255-i, 0))
  13.  
  14. draw.line((0, (num-i)*img.size[1]/num, i*img.size[0]/num, 0), (0, 255-i, 0))
  15. draw.line((0, (i)*img.size[1]/num, i*img.size[0]/num, img.size[1]), (0, 255-i, 0))
  16. i-=1
  17.  
  18. del draw
  19.  
  20. # write to stdout
  21. img.save(sys.stdout, "PNG")
Success #stdin #stdout 0.19s 12416KB
stdin
import Image, ImageDraw, sys
 
dimensions = (400, 350)
img = Image.new("RGB", dimensions)
 
draw = ImageDraw.Draw(img)
num =148
 
i = num
while (i>0) : 
   draw.line((i*img.size[0]/num, 0, img.size[0], i*img.size[1]/num), (0, 255-i, 0))
   draw.line(((num-i)*img.size[0]/num, img.size[1], img.size[0], i*img.size[1]/num), (0, 255-i, 0))
   
   draw.line((0, (num-i)*img.size[1]/num, i*img.size[0]/num, 0), (0, 255-i, 0)) 
   draw.line((0, (i)*img.size[1]/num, i*img.size[0]/num, img.size[1]), (0, 255-i, 0))  
   i-=1
 
del draw 
 
# write to stdout
img.save(sys.stdout, "PNG")
stdout