Python Imaging Library:ImageDraw Module(图像绘制模块)
# 图像绘制库
Mode_NewImg = "RGB"
Width_NewImg = 1000
Height_NewImg = 1000
Color_NewImg = "#78b8e7"
PilImg_Draw = Image.new(Mode_NewImg, (Width_NewImg, Height_NewImg),
                        Color_NewImg)

# 绘制图像
Draw = ImageDraw.Draw(PilImg_Draw)

# 绘制圆弧(arc)
# draw.arc(xy, start, end, options)
# draw.arc([x1, y1, x2, y2], startAngle, endAngle, options)
# 在左上角坐标为(x1,y1),右下角坐标为 (x2,y2)的矩形区域内,
# 以starangle为起始角度,endAngle为终止角度,
# 截取圆O的一部分圆弧绘制出来。如果[x1,y1,x2,y2]区域不是正方形,
# 则在该区域内的最大椭圆中根据角度截取片段。注意:
# [x1,y1,x2,y2]规定矩形框的水平中位线为0度角,
# 角度顺时针变大(与数学坐标系规定方向相反),
# 绘制一个90度蓝色圆弧
Draw.arc((0, 0) + (PilImg_Draw.width/2, PilImg_Draw.height/2),
         30, 150, fill="blue")
# 绘制一个红色上半圆弧
Draw.arc((0, 0) + (PilImg_Draw.width/2, PilImg_Draw.height/2),
         180, 360, fill="red")
# 绘制一个右半椭圆,只需改区域大小为长方形
Draw.arc((0, 0) + (PilImg_Draw.width/2, PilImg_Draw.height/2-150),
         90, 270, fill="green")

# 绘制正弦(chord)
# Draw.chord(xy, start, end, options)
# 用法与arc相同,用来画圆从startAngle到endAngle的弦。
# 绘制一条弦
Draw.chord((PilImg_Draw.width/2, 0) +
           (PilImg_Draw.width, PilImg_Draw.height/2),
           270, 360, outline="red")
# 绘制弦并且将弦与弧包围区域涂色
Draw.chord((PilImg_Draw.width/2, 0) +
           (PilImg_Draw.width, PilImg_Draw.height/2),
           90, 180, fill="red")

# 绘制椭圆(ellipse)
# draw.ellipse(xy, options)
Draw.ellipse((PilImg_Draw.width/2, 100) +
             (PilImg_Draw.width, PilImg_Draw.height/2-100),
             outline=128)
Draw.ellipse((PilImg_Draw.width/2, 100) +
             (PilImg_Draw.width, PilImg_Draw.height/2-100),
             fill="blue")

# 绘制直线(line)
# draw.line(xy, options)
Draw.line((0, 0) + PilImg_Draw.size, fill=128)
Draw.line((0, PilImg_Draw.size[1], PilImg_Draw.size[0], 0), fill=128)

# 绘制起始角度间的扇形区域(pieslice)
# draw.pieslice(xy, start, end, options)
# 绘制180度到210度的扇形区域轮廓
Draw.pieslice((0, PilImg_Draw.height/2) +
              (PilImg_Draw.width/2, PilImg_Draw.height),
              180, 210, outline=128)
# 绘制60度到90度的扇形区域
Draw.pieslice((0, PilImg_Draw.height/2) +
              (PilImg_Draw.width/2, PilImg_Draw.height),
              60, 90, fill="blue")

# 绘制点(point)
# draw.point(xy, options)
Draw.point((PilImg_Draw.width/2, PilImg_Draw.height/2+10),
           fill="black")

# 绘制多边形(polygon)
# draw.polygon(xy, options)
Draw.polygon([(200, 200), (600, 300), (300, 600)],
             outline="green")
Draw.polygon([(300, 300), (500, 300), (300, 500), (500, 500)],
             fill="#34a2b6")
             
# 绘制矩形(rectangle)
# draw.rectangle(box, options)
Draw.rectangle((750, 750, 850, 850), outline="red")
Draw.rectangle((850, 850, 900, 920), fill="#9934c5")
               
# 绘制文本(text)
# draw.text(position, string, options)
Text = "I love python!"
Draw.text([600, 600], Text, "red")

# 获取文本位置
# width, height = Draw.textsize(Text, "red")
# print("文本位置:", width, height)
PilImg_Draw.show()

Python Imaging Library:ImageDraw Module(图像绘制模块)相关推荐

  1. Python Imaging Library: ImageFile Module(图像文件模块)

    Python Imaging Library: ImageFile Module(图像文件模块) ImageFile模块为图像打开和保存功能提供了支持函数. 此外,它还提供了一个解析器类,可以被用来对 ...

  2. Python Imaging Library: ImageEnhance Module(图像增强模块)

    Python Imaging Library: ImageEnhance Module(图像增强模块) # 图像增强模块(ImageEnhance Module) PilImg_Enhance = I ...

  3. Python Imaging Library: ImageSequence Module(图像序列模块)

    Python Imaging Library: ImageSequence Module(图像序列模块) ImageSequence模块包含一个包装器类,可以让您遍历图像序列中的所有帧. Functi ...

  4. Python Imaging Library: ImageWin Module(图像Windows模块)

    Python Imaging Library: ImageWin Module(图像Windows模块) ImageWin模块支持在Windows上创建和显示图像. ImageWin可以与Python ...

  5. Python Imaging Library: ImagePath Module(图像路径模块)

    Python Imaging Library: ImagePath Module(图像路径模块) ImagePath模块用于存储和操作二维向量数据.路径对象可以在 ImageDraw 模块中传递方法. ...

  6. Python Imaging Library: ImageTk Module(图像Tkinter模块)

    Python Imaging Library: ImageTk Module(图像Tkinter模块) ImageTk模块支持从图片中创建和修改Tkinter位图图像和PhotoImage对象. 例如 ...

  7. Python Imaging Library: ImageQt Module(图像QT模块)

    Python Imaging Library: ImageQt Module(图像QT模块) (版本1.1.6) ImageQt 模块支持从图片中创建PyQt4 QImage对象. 注意:如果你使用的 ...

  8. Python Imaging Library: ImagePalette Module(图像调色板模块)

    Python Imaging Library: ImagePalette Module(图像调色板模块) FIXME: 这个部分不太符合当前现状.现在,将调色板添加到图像的最安全的方法是在字符串中使用 ...

  9. Python Imaging Library: ImageOps Module(图像运算模块)

    Python Imaging Library: ImageOps Module(图像运算模块) (版本1.1.3) ImageOps模块包含许多"现成的"图像处理操作.这个模块是实 ...

最新文章

  1. win32 api setwindowlong 第2个参数_第 6 篇:分页接口
  2. 御用导航官方网站提醒提示页_电脑上使用便签记录工作计划如何设置闹钟定时提醒?...
  3. 监测linux一些重要文件md5值脚本
  4. misc高阶 攻防世界_攻防世界 Misc 进阶题(一)
  5. 每天一道LeetCode-----有效回文串
  6. ecmall支持php5.3,在PHP5.3以上版本运行ecshop和ecmall出现的问题及解决方案
  7. Harmonic Number (II) LightOJ - 1245(找规律?大数f(n)=n/1+n/2+n/3+......+n/n)
  8. 二三星缩水软件手机版_还在抱怨三星手机不好用?用这些软件立马解决
  9. aspose 转pdf表格大小乱了_自己写了一个小工具类:pdf转word,没有页数和大小限制,保真!...
  10. 电商:购物车模块解决思路
  11. linux输入过的命令行,LINUX中命令行的历史记录和编辑
  12. 【OUTLINE】使用Oracle Outline技术暂时锁定SQL的执行计划
  13. 分布式缓存MemcacheHelper
  14. Un*、IdL分别突变情况下双闭环直流调速系统仿真
  15. 搜索引擎优化的九大方法
  16. Android --- 5G网络,android系统开发教程
  17. 这次经历给我埋下了学理财的种子
  18. 服务器系统排行榜,服务器操作系统排行榜
  19. 【编程语言选择】我们学C++将来能做什么?
  20. lscpu与cat /proc/cpuinfo获取的CPU信息释义

热门文章

  1. C++ char 类型:字符型和最小的整型
  2. [Swift]LeetCode890. 查找和替换模式 | Find and Replace Pattern
  3. linux如何删除行首的空格
  4. Mac adb 安装
  5. ko学习二,绑定语法
  6. 在线报表设计实战系列 – 制作动态列与静态列混排的报表(5)
  7. 20162309《程序设计与数据结构》第二学期课程总结
  8. Django【基础篇】
  9. 面向云的.net core开发框架
  10. 在线CSV转SQL工具