Advertisement
ClearCode

Shapes

May 18th, 2022
2,416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. from PIL import Image, ImageDraw, ImageFont
  2.  
  3. # image import
  4. image = Image.open('picture.jpg')
  5. draw = ImageDraw.Draw(image) # creates a draw object
  6.  
  7. # draw shapes
  8. draw.rectangle((200,400,700,600), fill = (255,0,0), outline = 'yellow', width = 5)
  9. draw.ellipse((200,400,700,600), fill = (255,0,255), outline = 'purple', width = 5)
  10. draw.polygon(((0,0),(100,0),(100,100),(50,200)),fill = 'blue',outline = 'pink')
  11. draw.line(((800,1000),(1000,1100),(1200,1000)),fill = 'black', width = 10, joint = 'curve')
  12.  
  13. # draw circle thingies
  14. # draw.arc((800,100,1000,300),start = 10, end = 40, width = 10, fill = 'red')
  15. # draw.chord((800,100,1000,300),start = 10, end = 180, width = 10, fill = 'red')
  16. draw.pieslice((800,100,1000,300),start = 10, end = 180, width = 10, fill = 'red')
  17.  
  18. # draw text
  19. font = ImageFont.truetype('Halogen.ttf', size = 80)
  20. draw.text((1300,640),'panda', font = font, fill = (0,255,255), align = 'center', anchor = 'rt')
  21.  
  22.  
  23. image.save('18.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement