fork(1) download
  1. import Image, ImageDraw, sys, ImageFont
  2.  
  3. XMax = int(raw_input())
  4. YMax = int(raw_input())
  5.  
  6. dimensions = (XMax, YMax)
  7. img = Image.new("RGB", dimensions)
  8.  
  9. draw = ImageDraw.Draw(img)
  10.  
  11. num = int(raw_input())
  12.  
  13. i = num
  14. while (i>0) :
  15. draw.line((i*img.size[0]/num, 0, img.size[0], i*img.size[1]/num), (0, 255-i, 0))
  16. draw.line(((num-i)*img.size[0]/num, img.size[1], img.size[0], i*img.size[1]/num), (0, 255-i, 0))
  17.  
  18. draw.line((0, (num-i)*img.size[1]/num, i*img.size[0]/num, 0), (0, 255-i, 0))
  19. draw.line((0, (i)*img.size[1]/num, i*img.size[0]/num, img.size[1]), (0, 255-i, 0))
  20. i-=1
  21.  
  22. # text
  23. font = ImageFont.truetype("/usr/local/share/fonts/UbuntuMono-B.ttf", 50)
  24. font2 = ImageFont.truetype("/usr/local/share/fonts/UbuntuMono-B.ttf", 40)
  25. draw=ImageDraw.Draw(img)
  26. draw.text((75, 100), 'Hacker', fill=(255,255,255), font=font)
  27. draw.text((140, 140), 'News', fill=(200,200,200), font=font2)
  28. del draw
  29.  
  30. # write to stdout
  31. img.save(sys.stdout, "PNG")
Success #stdin #stdout 0.19s 13072KB
stdin
300
300
48
stdout