本文整理匯總了TypeScript中app/model/paths.Path.getCommand方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Path.getCommand方法的具體用法?TypeScript Path.getCommand怎麽用?TypeScript Path.getCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app/model/paths.Path
的用法示例。
在下文中一共展示了Path.getCommand方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: autoConvertSubPath
function autoConvertSubPath(from: Path, to: Path, subIdx: number): [Path, Path] {
const numFrom = from.getSubPath(subIdx).getCommands().length;
const numTo = to.getSubPath(subIdx).getCommands().length;
if (numFrom !== numTo) {
// Only auto convert when the number of commands in both subpaths are equal.
return [from, to];
}
const fromPm = from.mutate();
const toPm = to.mutate();
for (let cmdIdx = 0; cmdIdx < numFrom; cmdIdx++) {
const fromCmd = from.getCommand(subIdx, cmdIdx);
const toCmd = to.getCommand(subIdx, cmdIdx);
if (fromCmd.type === toCmd.type) {
continue;
}
if (fromCmd.canConvertTo(toCmd.type)) {
fromPm.convertCommand(subIdx, cmdIdx, toCmd.type);
} else if (toCmd.canConvertTo(fromCmd.type)) {
toPm.convertCommand(subIdx, cmdIdx, fromCmd.type);
}
}
return [fromPm.build(), toPm.build()];
}