本文整理汇总了Python中stack.Stack.mult方法的典型用法代码示例。如果您正苦于以下问题:Python Stack.mult方法的具体用法?Python Stack.mult怎么用?Python Stack.mult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stack.Stack
的用法示例。
在下文中一共展示了Stack.mult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_file
# 需要导入模块: from stack import Stack [as 别名]
# 或者: from stack.Stack import mult [as 别名]
def parse_file( fname, screen, pen ):
# transformation matrix stack
stack = Stack()
# Iterating over the file so we can keep it open
# Allows us to use stdin
with open(fname) as fd:
itr = iter(fd)
# Do not loop through the list because we need to get multiple elements
while True:
cmd = next(itr, "quit").strip().lower()
# Skip comments and blank lines
if cmd == '' or cmd[0] == '#':
continue
print cmd
# 2-D drawing routines
if cmd == "line":
args = next(itr).strip().lower().split()
x0 = float(args[0])
y0 = float(args[1])
z0 = float(args[2])
x1 = float(args[3])
y1 = float(args[4])
z1 = float(args[5])
# Immediately draw line to screen
edges = []
add_edge(edges, x0, y0, z0, x1, y1, z1)
mmult(stack.peek(), edges)
draw_lines(edges, screen, pen)
elif cmd == "circle" or cmd == "c":
args = next(itr).strip().lower().split()
cx = float(args[0])
cy = float(args[1])
cz = 0
r = float(args[2])
step = 1/round(4 * sqrt(r))
# Immediately draw curve to screen
edges = []
add_circle(edges, cx, cy, cz, r, step)
mmult(stack.peek(), edges)
draw_lines(edges, screen, pen)
elif cmd == "hermite" or cmd == "h":
args = next(itr).strip().lower().split()
x = [float(s) for s in args[:4]]
y = [float(s) for s in args[4:]]
# Immediately draw curve to screen
edges = []
add_curve(edges, x[0], x[1], x[2], x[3], y[0], y[1], y[2], y[3], 0.05, HERMITE)
mmult(stack.peek(), edges)
draw_lines(edges, screen, pen)
elif cmd == "bezier" or cmd == "b":
args = next(itr).strip().lower().split()
x = [float(s) for s in args[:4]]
y = [float(s) for s in args[4:]]
# Immediately draw curve to screen
edges = []
add_curve(edges, x[0], x[1], x[2], x[3], y[0], y[1], y[2], y[3], 0.05, BEZIER)
mmult(stack.peek(), edges)
draw_lines(edges, screen, pen)
# 3-D drawing routines
elif cmd == "box":
args = next(itr).strip().lower().split()
x = float(args[0])
y = float(args[1])
z = float(args[2])
width = float(args[3])
height = float(args[4])
depth = float(args[5])
polygons = []
add_box(polygons, x, y, z, width, height, depth)
mmult(stack.peek(), polygons)
draw_polygons(polygons, screen, pen)
elif cmd == 'sphere':
args = next(itr).strip().lower().split()
x = float(args[0])
y = float(args[1])
z = 0
r = float(args[2])
step = int(round(2 * sqrt(r)))
polygons = []
add_sphere(polygons, x, y, z, r, step)
mmult(stack.peek(), polygons)
draw_polygons(polygons, screen, pen)
elif cmd == 'torus':
#.........这里部分代码省略.........