分形图

分形图,第1张

概述分形图

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

#!/usr/bin/env python3"""      turtle-example-suite:        tdemo_bytedesign.pyAn example adapted from the example-suiteof PythonCard's turtle graphics.It's based on an article in BYTE magazineProblem Solving with logo: Using TurtleGraphics to Redraw a DesignNovember 1982,p. 118 - 134-------------------------------------------Due to the statementt.delay(0)in line 152,which sets the animation delayto 0,this animation runs in "line per line"mode as fast as possible."""import mathfrom turtle import Turtle,mainloopfrom time import clock# wrapper for any additional drawing routines# that need to kNow about each otherclass Designer(Turtle):    def design(self,homePos,scale):        self.up()        for i in range(5):            self.forward(64.65 * scale)            self.down()            self.wheel(self.position(),scale)            self.up()            self.backward(64.65 * scale)            self.right(72)        self.up()        self.goto(homePos)        self.right(36)        self.forward(24.5 * scale)        self.right(198)        self.down()        self.centerpIEce(46 * scale,143.4,scale)        self.getscreen().tracer(True)    def wheel(self,initpos,scale):        self.right(54)        for i in range(4):            self.pentpIEce(initpos,scale)        self.down()        self.left(36)        for i in range(5):            self.tripIEce(initpos,scale)        self.left(36)        for i in range(5):            self.down()            self.right(72)            self.forward(28 * scale)            self.up()            self.backward(28 * scale)        self.left(54)        self.getscreen().update()    def tripIEce(self,scale):        oldh = self.heading()        self.down()        self.backward(2.5 * scale)        self.tripolyr(31.5 * scale,scale)        self.up()        self.goto(initpos)        self.setheading(oldh)        self.down()        self.backward(2.5 * scale)        self.tripolyl(31.5 * scale,scale)        self.up()        self.goto(initpos)        self.setheading(oldh)        self.left(72)        self.getscreen().update()    def pentpIEce(self,scale):        oldh = self.heading()        self.up()        self.forward(29 * scale)        self.down()        for i in range(5):            self.forward(18 * scale)            self.right(72)        self.pentr(18 * scale,75,scale)        self.up()        self.goto(initpos)        self.setheading(oldh)        self.forward(29 * scale)        self.down()        for i in range(5):            self.forward(18 * scale)            self.right(72)        self.pentl(18 * scale,scale)        self.up()        self.goto(initpos)        self.setheading(oldh)        self.left(72)        self.getscreen().update()    def pentl(self,sIDe,ang,scale):        if sIDe < (2 * scale): return        self.forward(sIDe)        self.left(ang)        self.pentl(sIDe - (.38 * scale),scale)    def pentr(self,scale):        if sIDe < (2 * scale): return        self.forward(sIDe)        self.right(ang)        self.pentr(sIDe - (.38 * scale),scale)    def tripolyr(self,scale):        if sIDe < (4 * scale): return        self.forward(sIDe)        self.right(111)        self.forward(sIDe / 1.78)        self.right(111)        self.forward(sIDe / 1.3)        self.right(146)        self.tripolyr(sIDe * .75,scale)    def tripolyl(self,scale):        if sIDe < (4 * scale): return        self.forward(sIDe)        self.left(111)        self.forward(sIDe / 1.78)        self.left(111)        self.forward(sIDe / 1.3)        self.left(146)        self.tripolyl(sIDe * .75,scale)    def centerpIEce(self,s,a,scale):        self.forward(s); self.left(a)        if s < (7.5 * scale):            return        self.centerpIEce(s - (1.2 * scale),scale)def main():    t = Designer()    t.speed(0)    t.hIDeturtle()    t.getscreen().delay(0)    t.getscreen().tracer(0)    at = clock()    t.design(t.position(),2)    et = clock()    return "runtime: %.2f sec." % (et-at)if __name__ == '__main__':    msg = main()    print(msg)    mainloop()

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的分形图全部内容,希望文章能够帮你解决分形图所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1198656.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存