當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Matrix.rotation方法代碼示例

本文整理匯總了TypeScript中app/scripts/common.Matrix.rotation方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Matrix.rotation方法的具體用法?TypeScript Matrix.rotation怎麽用?TypeScript Matrix.rotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app/scripts/common.Matrix的用法示例。


在下文中一共展示了Matrix.rotation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: fromPathOpString

export function fromPathOpString(pathString: string, pathOpsString: string) {
  const A = pathOpsString.split(' ');
  const mutator = new Path(pathString).mutate();
  for (let i = 0; i < A.length; i++) {
    const op = A[i] as PathOp;
    switch (op) {
      case 'RV': // Reverse.
        mutator.reverseSubPath(+A[i + 1]);
        i += 1;
        break;
      case 'SB': // Shift back.
        mutator.shiftSubPathBack(+A[i + 1]);
        i += 1;
        break;
      case 'SF': // Shift forward.
        mutator.shiftSubPathForward(+A[i + 1]);
        i += 1;
        break;
      case 'S': // Split.
        const subIdx = +A[i + 1];
        const cmdIdx = +A[i + 2];
        const args = [+A[i + 3]];
        i += 3;
        while (!isNaN(+A[i + 1]) && i < A.length) {
          args.push(+A[i + 1]);
          i++;
        }
        mutator.splitCommand(subIdx, cmdIdx, ...args);
        break;
      case 'SIH': // Split in half.
        mutator.splitCommandInHalf(+A[i + 1], +A[i + 2]);
        i += 2;
        break;
      case 'US': // Unsplit.
        mutator.unsplitCommand(+A[i + 1], +A[i + 2]);
        i += 2;
        break;
      case 'CV': // Convert.
        mutator.convertCommand(+A[i + 1], +A[i + 2], A[i + 3] as SvgChar);
        i += 3;
        break;
      case 'UCV': // Unconvert.
        mutator.unconvertSubPath(+A[i + 1]);
        i += 1;
        break;
      case 'RT': // Revert.
        mutator.revert();
        break;
      case 'M': // Move subpath.
        mutator.moveSubPath(+A[i + 1], +A[i + 2]);
        i += 2;
        break;
      case 'AC': // Add collapsing sub path.
        mutator.addCollapsingSubPath({ x: +A[i + 1], y: +A[i + 2] }, +A[i + 3]);
        i += 3;
        break;
      case 'DC': // Delete collapsing sub paths.
        mutator.deleteCollapsingSubPaths();
        break;
      case 'SSSP': // Split stroked sub path.
        mutator.splitStrokedSubPath(+A[i + 1], +A[i + 2]);
        i += 2;
        break;
      case 'SFSP': // Split filled sub path.
        mutator.splitFilledSubPath(+A[i + 1], +A[i + 2], +A[i + 3]);
        i += 3;
        break;
      case 'DFSP': // Delete filled sub path.
        mutator.deleteFilledSubPath(+A[i + 1]);
        i += 1;
        break;
      case 'DFSPS': // Delete filled subpath segment.
        mutator.deleteFilledSubPathSegment(+A[i + 1], +A[i + 2]);
        i += 2;
        break;
      case 'DSSP': // Delete stroked sub path.
        mutator.deleteStrokedSubPath(+A[i + 1]);
        i += 1;
        break;
      case 'T': // Transform.
        const isTransformOpFn = (token: string) => {
          token = (token || '').toLowerCase();
          return new Set(['scale', 'rotate', 'translate']).has(token);
        };
        while (isTransformOpFn(A[i + 1])) {
          const transformOp = A[i + 1];
          let matrix: Matrix;
          switch (transformOp) {
            case 'scale':
              matrix = Matrix.scaling(+A[i + 2], +A[i + 3]);
              i += 3;
              break;
            case 'rotate':
              matrix = Matrix.rotation(+A[i + 2]);
              i += 2;
              break;
            case 'translate':
              matrix = Matrix.translation(+A[i + 2], +A[i + 3]);
              i += 3;
              break;
//.........這裏部分代碼省略.........
開發者ID:arpitsaan,項目名稱:ShapeShifter,代碼行數:101,代碼來源:PathUtil.ts


注:本文中的app/scripts/common.Matrix.rotation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。