本文摘自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画图的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
关于Python 下划线使用场景
Python使用matplotlib绘制饼图
Python中subprocess库的用法介绍
Python如何使用文本框
Python数据爬下来保存在哪里
解决pycharm找不到解释器的问题
Python注释快捷键是什么
Python如何随机生成10个整数
Python单词怎么读
Python是开源的,它可以被移植到许多平台上,是对的吗?
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » rectangle是什么意思,如何利用elipse和rectangle画图