Lines Matching full:commands
30 """Takes a T2CharString program list and returns list of commands.
37 commands = []
52 commands.append(('', [width]))
56 commands.append(('', stack))
57 commands.append((token, []))
58 commands.append(('', [next(it)]))
60 commands.append((token,stack))
63 commands.append(('', stack))
64 return commands
67 def commandsToProgram(commands): argument
68 """Takes a commands list as returned by programToCommands() and converts
71 for op,args in commands:
207 def generalizeCommands(commands, ignoreErrors=False): argument
210 for op,args in commands:
220 # Store op as data, such that consumers of commands do not have to
270 def specializeCommands(commands, argument
278 # 0. Generalize commands.
307 # 0. Generalize commands.
309 commands = generalizeCommands(commands, ignoreErrors=ignoreErrors)
311 commands = list(commands) # Make copy since we modify in-place later.
314 for i in range(len(commands)-1, 0, -1):
315 if 'rmoveto' == commands[i][0] == commands[i-1][0]:
316 v1, v2 = commands[i-1][1], commands[i][1]
317 commands[i-1] = ('rmoveto', [v1[0]+v2[0], v1[1]+v2[1]])
318 del commands[i]
366 for i in range(len(commands)):
367 op,args = commands[i]
371 commands[i] = c+op[1:], args
377 commands[i] = c1+c2+'curveto', args1+args[2:4]+args2
403 for i in range(len(commands)-1, -1, -1):
404 op, args = commands[i]
411 commands[i] = op, args
416 del commands[i]
421 (op == commands[i-1][0]) and
423 _, other_args = commands[i-1]
425 commands[i-1] = (op, [other_args[0]+args[0]])
426 del commands[i]
431 for i in range(1, len(commands)-1):
432 op,args = commands[i]
433 prv,nxt = commands[i-1][0], commands[i+1][0]
438 commands[i] = ('rlineto', args)
453 commands[i] = ('rrcurveto', args)
457 for i in range(len(commands)-1, 0, -1):
458 op1,args1 = commands[i-1]
459 op2,args2 = commands[i]
503 commands[i-1] = (new_op, args1+args2)
504 del commands[i]
507 for i in range(len(commands)):
508 op,args = commands[i]
511 commands[i] = 'h'+op[1:], args
534 commands[i] = op0+op1+'curveto', args
537 return commands
550 commands = programToCommands(program) variable
551 print("Commands:"); print(commands)
552 program2 = commandsToProgram(commands)
553 print("Program from commands:"); print(programToString(program2))