当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ekkiog-editing.createForest函数代码示例

本文整理汇总了TypeScript中ekkiog-editing.createForest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createForest函数的具体用法?TypeScript createForest怎么用?TypeScript createForest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createForest函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: create

export default function* create({name} : CreateForestAction) {
  yield put(newContextLoading('', name));
  const forest = createForest();
  const hash = yield storage.create(name, forest);
  yield put(forestLoaded(createForest(), hash, false));
  yield put(setUrl('', name));
};
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:7,代码来源:createForest.ts

示例2: insertMovableItem

function* insertMovableItem(initialForest : Forest, tool : Tool, direction : Direction, x : number, y : number){
  const forest = tap(createForest(initialForest.buddyTree), tool, direction, x, y);
  const item = getTileAt(forest, x, y);

  const ok = yield* selection(item);
  if(ok){
    yield put(saveForest(`Inserted ${tool}`));
  }
};
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:9,代码来源:tapTile.ts

示例3: loadOrCreate

export function* loadOrCreate(repo : string, name : string, hash? : string){
  if(repo.length === 0){
    try{
      return yield* loadOrPull(repo, name, hash);
    }catch(e){
      console.log(e);
      const forest = createForest();
      const hash = yield storage.create(name, forest);
      return {
        ...forest,
        hash
      };
    }
  }else{
    return yield* loadOrPull(repo, name, hash);
  }
}
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:17,代码来源:loadForest.ts

示例4: editing

export default function editing(forest=createForest(), action : Action) : Forest{
  switch(action.type){
    case 'set-forest':
      return action.forest || forest;
    case 'draw':
      return tap(forest, action.tool, action.direction, action.x, action.y);
    case 'remove-tile-at':
      return clear(forest, action.x, action.y);
    case 'convert-wire-to-underpass':
      return wireToUnderpass(forest, action.x, action.y);
    case 'convert-underpass-to-wire':
      return underpassToWire(forest, action.x, action.y);
    case 'insert-component':
      return drawComponent(forest, action.position.x+(action.component.width>>1), action.position.y+(action.component.height>>1), action.component);
    default:
      return forest;
  }
}
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:18,代码来源:forest.ts

示例5: xor

export default function xor(){
  let forest = createForest();
  forest = drawButton(forest, 58, 62);
  forest = drawButton(forest, 58, 66);
  forest = drawWire(forest, 60, 63);
  forest = drawWire(forest, 60, 62);
  forest = drawWire(forest, 60, 61);
  forest = drawWire(forest, 61, 61);
  forest = drawWire(forest, 62, 61);
  forest = drawWire(forest, 63, 61);
  forest = drawWire(forest, 64, 61);
  forest = drawWire(forest, 65, 61);

  forest = drawWire(forest, 60, 65);
  forest = drawWire(forest, 60, 66);
  forest = drawWire(forest, 60, 67);
  forest = drawWire(forest, 61, 67);
  forest = drawWire(forest, 62, 67);
  forest = drawWire(forest, 63, 67);
  forest = drawWire(forest, 64, 67);
  forest = drawWire(forest, 65, 67);

  forest = drawGate(forest, 64, 64);
  forest = drawWire(forest, 65, 63);
  forest = drawWire(forest, 65, 64);
  forest = drawWire(forest, 65, 65);

  forest = drawGate(forest, 69, 62);
  forest = drawGate(forest, 69, 66);

  forest = drawWire(forest, 70, 62);
  forest = drawWire(forest ,70, 63);

  forest = drawWire(forest, 70, 65);
  forest = drawWire(forest ,70, 66);

  forest = drawGate(forest, 74, 64);
  forest = drawLight(forest, 76, 64);

  return forest;
}
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:41,代码来源:xor.ts

示例6: and

export default function and(){
  let forest = createForest();
  forest = drawButton(forest, 58, 62);
  forest = drawWire(forest, 60, 62);
  forest = drawWire(forest, 60, 63);

  forest = drawButton(forest, 58, 66);
  forest = drawWire(forest, 60, 66);
  forest = drawWire(forest, 60, 65);

  forest = drawGate(forest, 64, 64);

  forest = drawWire(forest, 65, 63);
  forest = drawWire(forest, 65, 64);
  forest = drawWire(forest, 65, 65);

  forest = drawGate(forest, 69, 64);

  forest = drawLight(forest, 71, 64);
  return forest;
}
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:21,代码来源:and.ts

示例7: zomOutOf

export default function* zomOutOf({} : ZoomOutOfAction){
  const { context: currentContext, selection: {selection: isSelection}} : State = yield select();

  if(isSelection){
    yield put(stopSelection());
    yield put(resetEditorMenu());
  }

  const outerContext = currentContext.previous;
  if(!outerContext) return;

  const innerContext : ContextState = yield* waitUntilSaved(currentContext);

  yield put(popContext());
  yield put(setUrl(outerContext.repo, outerContext.name));
  if(innerContext.isReadOnly || outerContext.isReadOnly) return;

  const pkg = packageComponent(innerContext.forest, innerContext.repo, innerContext.name, innerContext.hash, innerContext.hash);
  const {forest, didntFit} = replaceComponents(outerContext.forest, pkg);
  if(outerContext.forest !== forest){
    yield put(setForest(forest));
  }

  for(const position of didntFit) {
    yield put(removeTileAt(position.x, position.y));
    const {context: {forest: newForest}} : State = yield select();

    const forest = drawComponent(createForest(newForest.buddyTree), position.x, position.y, pkg);

    const item = getTileAt(forest, position.x, position.y);
    yield* selection(item);
  };

  const { context: newContext } : State = yield select();
  if(outerContext.forest !== newContext.forest){
    yield put(saveForest(`Updated ${pkg.name}`));
  }
}
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:38,代码来源:zoomOutOf.ts

示例8: insertComponentPackage

export default function* insertComponentPackage({componentPackage} : InsertComponentPackageAction){
  const state : State = yield select();

  if(state.selection.selection){
    yield put(stopSelection());
    yield put(resetEditorMenu());
  }

  const tile = state.view.viewportToTile(state.view.pixelWidth/2, state.view.pixelHeight/2);
  const centerTile = {
    x: tile[0]|0,
    y: tile[1]|0
  };

  const forest = drawComponent(createForest(state.context.forest.buddyTree), centerTile.x, centerTile.y, componentPackage);

  const item = getTileAt(forest, centerTile.x, centerTile.y);

  const ok = yield* selection(item);
  if(ok){
    yield put(saveForest(`Inserted ${componentPackage.name}`));
  }
}
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:23,代码来源:insertComponentPackage.ts

示例9: createForest

  readonly count : number
}

export interface LoadingState {
  readonly repo : string
  readonly name : string
  readonly scaleInFrom : number
  readonly abort : ContextState
}

const initialContext : ContextState = {
  repo: 'to open a component',
  name: 'Click here',
  isReadOnly: true,
  hash: '0000000000000000000000000000000000000000',
  forest: createForest(),
  buttonTree: createButtonTree(256*256),
  boundingBox: {
    top: 56,
    left: 56,
    right: 72,
    bottom: 72
  },
  ease: noEase(boxToArray({
    top: 56,
    left: 56,
    right: 72,
    bottom: 72
  })),
  saving: false
}
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:31,代码来源:context.ts


注:本文中的ekkiog-editing.createForest函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。