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


TypeScript LayerUtil.getCanvasTransformsForGroupLayer方法代码示例

本文整理汇总了TypeScript中app/model/layers.LayerUtil.getCanvasTransformsForGroupLayer方法的典型用法代码示例。如果您正苦于以下问题:TypeScript LayerUtil.getCanvasTransformsForGroupLayer方法的具体用法?TypeScript LayerUtil.getCanvasTransformsForGroupLayer怎么用?TypeScript LayerUtil.getCanvasTransformsForGroupLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app/model/layers.LayerUtil的用法示例。


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

示例1:

 const layerChildren = layer.children.map((l: GroupLayer | PathLayer | ClipPathLayer): Layer => {
   if (l instanceof GroupLayer) {
     const flattenedTransform = Matrix.flatten([
       layerTransform,
       ...LayerUtil.getCanvasTransformsForGroupLayer(l),
     ]);
     const { sx, sy } = flattenedTransform.getScaling();
     const degrees = flattenedTransform.getRotation();
     const { tx, ty } = flattenedTransform.getTranslation();
     const newLayer = l.clone();
     newLayer.pivotX = 0;
     newLayer.pivotY = 0;
     newLayer.translateX = tx;
     newLayer.translateY = ty;
     newLayer.rotation = degrees;
     newLayer.scaleX = sx;
     newLayer.scaleY = sy;
     return newLayer;
   }
   const path = l.pathData;
   if (!path || !l.pathData.getPathString()) {
     return l;
   }
   const clonedLayer = l.clone();
   clonedLayer.pathData = path
     .mutate()
     .transform(layerTransform)
     .build();
   return clonedLayer;
 });
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:30,代码来源:layertimeline.service.ts

示例2: flattenGroupLayer

 /**
  * Merges the specified group layer into its children layers.
  * TODO: make it possible to merge groups that contain animation blocks?
  */
 flattenGroupLayer(layerId: string) {
   const vl = this.getVectorLayer();
   const layer = vl.findLayerById(layerId) as GroupLayer;
   if (!layer.children.length) {
     return;
   }
   const layerTransform = Matrix.flatten(LayerUtil.getCanvasTransformsForGroupLayer(layer));
   const layerChildren = layer.children.map((l: GroupLayer | PathLayer | ClipPathLayer): Layer => {
     if (l instanceof GroupLayer) {
       const flattenedTransform = Matrix.flatten([
         layerTransform,
         ...LayerUtil.getCanvasTransformsForGroupLayer(l),
       ]);
       const { sx, sy } = flattenedTransform.getScaling();
       const degrees = flattenedTransform.getRotation();
       const { tx, ty } = flattenedTransform.getTranslation();
       const newLayer = l.clone();
       newLayer.pivotX = 0;
       newLayer.pivotY = 0;
       newLayer.translateX = tx;
       newLayer.translateY = ty;
       newLayer.rotation = degrees;
       newLayer.scaleX = sx;
       newLayer.scaleY = sy;
       return newLayer;
     }
     const path = l.pathData;
     if (!path || !l.pathData.getPathString()) {
       return l;
     }
     const clonedLayer = l.clone();
     clonedLayer.pathData = path
       .mutate()
       .transform(layerTransform)
       .build();
     return clonedLayer;
   });
   const layerChildrenIds = new Set(layerChildren.map(l => l.id));
   const parent = LayerUtil.findParent(vl, layerId).clone();
   const children = [...parent.children];
   children.splice(_.findIndex(parent.children, l => l.id === layerId), 1, ...layerChildren);
   parent.children = children;
   const actions: Action[] = [
     new SetVectorLayer(LayerUtil.updateLayer(vl, parent)),
     ...this.buildCleanupLayerIdActions(layerId),
   ];
   const newAnimation = this.getAnimation().clone();
   // TODO: show a dialog if the user is about to unknowingly delete any blocks?
   newAnimation.blocks = newAnimation.blocks.filter(b => b.layerId !== layerId);
   // TODO: also attempt to merge children group animation blocks?
   newAnimation.blocks = newAnimation.blocks.map(b => {
     if (!(b instanceof PathAnimationBlock) || !layerChildrenIds.has(b.layerId)) {
       return b;
     }
     const block = b.clone();
     block.fromValue = block.fromValue
       .mutate()
       .transform(layerTransform)
       .build();
     block.toValue = block.toValue
       .mutate()
       .transform(layerTransform)
       .build();
     return block;
   });
   actions.push(new SetAnimation(newAnimation));
   this.store.dispatch(new BatchAction(...actions));
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:72,代码来源:layertimeline.service.ts


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