Implement the function tree that takes a number of slices n and a rune as arguments, and generates a stack of runes scaled and overlayed on top of each other.
For example, the following command tree(4, circle_bb) should produce the following depth map:
The generated tree must satisfy a few properties: the circle bb at the top of the tree is scaled to 1=4 of its original size (the tree has 4 layers); the next lower layer is scaled by 2=4, and so on. Note that the bottom-most layer retains its original size. The different levels of the tree must also be spaced evenly apart.
要使用overlay_frac(比率,pattern1,pattern2)和scale(size,pattern)命令。在
对于overlay_frac,此参数确定 第一符文占据深度范围的一部分;剩余部分 深度范围将被第二个符文占据。在
我的代码特别显示(树(4,圆圈峎bb))是:
def tree(n, rune):
a= scale( 1/n, rune)
b = scale( 2/n, rune)
c = scale( 3/n, rune)
Bottom = overlay_frac( 1/2, c,d)
Middle = overlay_frac(1/2, b, Bottom)
Top = overlay_frac(1/2, a, Middle)
return Top
但我需要换成一个循环,所以我写下:
^{pr2}$然而,它给人的形象是不同的。我做错什么了?在
循环中有一个
return
语句,因此它在第一次迭代之后退出。在相关问题 更多 >
编程相关推荐