python图案代码⼤全_Python练习代码实例65-⼀个最优美的图
案
Python 练习实例65
题⽬:⼀个最优美的图案。
程序分析:⽆。
程序源代码:#!/usr/bin/python
# -*- coding: UTF-8 -*-
import math
class PTS:
def __init__(self):
self.x = 0
self.y = 0
points = []
def LineToDemo():
from Tkinter import *
screenx = 400
screeny = 400
canvas = Canvas(width = screenx,height = screeny,bg = 'white')
AspectRatio = 0.85
MAXPTS = 15
h = screeny
w = screenx
xcenter = w / 2
ycenter = h / 2
radius = (h - 30) / (AspectRatio * 2) - 20
step = 360 / MAXPTS
angle = 0.0
for i in range(MAXPTS):
rads = angle * math.pi / 180.0
p = PTS()
p.x = xcenter + s(rads) * radius)
p.y = ycenter - int(math.sin(rads) * radius * AspectRatio)
angle += step
python新手代码图案如何保存
points.append(p)
xcenter + radius,ycenter + radius)
for i in range(MAXPTS):
for j in range(i,MAXPTS):
mainloop()
if __name__ == '__main__':
LineToDemo()
以上实例输出结果为:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论