本文摘自php中文网,作者Tomorin,侵删。
本章我们来介绍用ellipse和rectangle画图,并且在例子中介绍rectangle是什么意思:Rectangle是一个函数,使用该函数画一个矩形,可以用当前的画笔画矩形轮廓,用当前画刷进行填充。什么是rectangle:
rectangle是存储一组整数,共四个,表示一个矩形的位置和大小
语法:
1 2 3 4 | [SerializableAttribute]
[TypeConverterAttribute( typeof (RectangleConverter))]
[ComVisibleAttribute( true )]
public struct Rectangle
|
程序源代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #!/usr/bin/python# -*- coding: UTF-8 -*-if __name__ == '__main__':
from Tkinter import *
canvas = Canvas(width = 400,height = 600,bg = 'white' )
left = 20
right = 50
top = 50
num = 15
for i in range(num):
canvas.create_oval(250 - right,250 - left,250 + right,250 + left)
canvas.create_oval(250 - 20,250 - top,250 + 20,250 + top)
canvas.create_rectangle(20 - 2 * i,20 - 2 * i,10 * (i + 2),10 * ( i + 2))
right += 5
left += 5
top += 10
canvas.pack()
mainloop()
|
以上实例输出结果为:

以上就是rectangle是什么意思,如何利用elipse和rectangle画图的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
Pythonn如何访问本地html
Python安装流程指南
sublime怎么写Python程序
Python堆排序算法实例代码
如何用Python整理附件
如何使用Python压缩/解压缩zip文件?(代码示例)
浅谈Python中字典append 到list 后值的改变
Python空类型是什么
Python什么是递归?两种优先搜索算法的实现 (代码示例)
Python整数怎么表示
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » rectangle是什么意思,如何利用elipse和rectangle画图