本文整理汇总了TypeScript中app/model/layers.LayerUtil类的典型用法代码示例。如果您正苦于以下问题:TypeScript LayerUtil类的具体用法?TypeScript LayerUtil怎么用?TypeScript LayerUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LayerUtil类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: swapLayers
/**
* Replaces an existing layer in the tree with a new layer. Note that
* this method assumes that both layers still have the same children layers.
*/
swapLayers(layerId: string, newLayer: Layer) {
if (layerId === newLayer.id) {
this.updateLayer(newLayer);
return;
}
const vl = this.getVectorLayer();
const parent = LayerUtil.findParent(vl, layerId).clone();
const layerIndex = _.findIndex(parent.children, l => l.id === layerId);
const children = [...parent.children];
children.splice(layerIndex, 1, newLayer);
parent.children = children;
const actions: Action[] = [
new SetVectorLayer(LayerUtil.updateLayer(vl, parent)),
...this.buildCleanupLayerIdActions(layerId),
];
const animation = this.getAnimation();
const oldLayerBlocks = animation.blocks.filter(b => b.layerId === layerId);
const newAnimatableProperties = new Set(newLayer.animatableProperties.keys());
// Preserve any blocks that are still animatable with the new layer.
const newLayerBlocks = oldLayerBlocks
.filter(b => newAnimatableProperties.has(b.propertyName))
.map(b => {
b = b.clone();
b.layerId = newLayer.id;
return b;
});
const newAnimation = animation.clone();
newAnimation.blocks = [
...animation.blocks.filter(b => b.layerId !== layerId),
...newLayerBlocks,
];
actions.push(new SetAnimation(newAnimation));
this.store.dispatch(new BatchAction(...actions));
}
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:38,代码来源:layertimeline.service.ts
示例2: while
tempSelLayers = tempSelLayers.filter(layer => {
if (layer instanceof VectorLayer) {
return false;
}
let p = LayerUtil.findParent(vl, layer.id);
while (p) {
if (_.find(tempSelLayers, l => l.id === p.id)) {
return false;
}
p = LayerUtil.findParent(vl, p.id);
}
return true;
});
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:13,代码来源:layertimeline.service.ts
示例3:
tempSelLayers.filter(layer => layer instanceof GroupLayer).forEach(groupLayer => {
// Move children into parent.
const parent = LayerUtil.findParent(vl, groupLayer.id).clone();
const indexInParent = Math.max(
0,
_.findIndex(parent.children, l => l.id === groupLayer.id),
);
const newChildren = [...parent.children];
newChildren.splice(indexInParent, 0, ...groupLayer.children);
parent.children = newChildren;
vl = LayerUtil.updateLayer(vl, parent);
newSelectedLayers.splice(0, 0, ...groupLayer.children);
// Delete the parent.
vl = LayerUtil.removeLayers(vl, groupLayer.id);
});
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:15,代码来源:layertimeline.service.ts
示例4: doesNameExistFn
const makeFinalNodeIdFn = (nodeId: string, prefix: string) => {
const finalName = LayerUtil.getUniqueName(
NameProperty.sanitize(nodeId || prefix),
name => doesNameExistFn(name) || usedIds.has(name),
);
usedIds.add(finalName);
return finalName;
};
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:8,代码来源:SvgLoader.ts
示例5: doesLayerNameExistFn
const makeFinalNodeIdFn = (value: string, prefix: string) => {
const finalName = LayerUtil.getUniqueName(
NameProperty.sanitize(value || prefix),
n => doesLayerNameExistFn(n) || usedNames.has(n),
);
usedNames.add(finalName);
return finalName;
};
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:8,代码来源:VectorDrawableLoader.ts
示例6: addLayer
/**
* Adds a layer to the vector tree.
*/
addLayer(layer: Layer) {
const vl = this.getVectorLayer();
const selectedLayers = this.getSelectedLayers();
if (selectedLayers.length === 1) {
const selectedLayer = selectedLayers[0];
if (!(selectedLayer instanceof VectorLayer)) {
// Add the new layer as a sibling to the currently selected layer.
const parent = LayerUtil.findParent(vl, selectedLayer.id).clone();
parent.children = [...parent.children, layer];
this.updateLayer(parent);
return;
}
}
const vectorLayer = vl.clone();
vectorLayer.children = [...vectorLayer.children, layer];
this.updateLayer(vectorLayer);
}
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:20,代码来源:layertimeline.service.ts
示例7: AnimationRenderer
(vl, anim, block) => {
if (!block) {
return undefined;
}
// Note this is a bit dangerous because the renderer interpolates paths
// and that causes all mutated path state to be lost if we aren't careful.
// There are currently checks in PathProperty.ts to avoid this by returning
// the start and end path when the interpolated fraction is 0 and 1 respectively.
const renderer = new AnimationRenderer(vl, anim);
const timeMillis = getTimeFn(block);
// First interpolate the entire vector layer.
const renderedVl = renderer.setCurrentTime(timeMillis);
// TODO: this is hacky! the real solution is to not clear path state after interpolations
// Replace the interpolated value with the block's to/from value.
const layer = vl.findLayerById(block.layerId).clone() as MorphableLayer;
layer.pathData = timeMillis === block.startTime ? block.fromValue : block.toValue;
return LayerUtil.updateLayer(renderedVl, layer);
},
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:18,代码来源:selectors.ts
示例8: groupOrUngroupSelectedLayers
/**
* Groups or ungroups the selected layers.
*/
groupOrUngroupSelectedLayers(shouldGroup: boolean) {
let selectedLayerIds = this.getSelectedLayerIds();
if (!selectedLayerIds.size) {
return;
}
let vl = this.getVectorLayer();
// Sort selected layers by order they appear in tree.
let tempSelLayers = Array.from(selectedLayerIds).map(id => vl.findLayerById(id));
const selLayerOrdersMap: Dictionary<number> = {};
let n = 0;
vl.walk(layer => {
if (_.find(tempSelLayers, l => l.id === layer.id)) {
selLayerOrdersMap[layer.id] = n;
n++;
}
});
tempSelLayers.sort((a, b) => selLayerOrdersMap[a.id] - selLayerOrdersMap[b.id]);
if (shouldGroup) {
// Remove any layers that are descendants of other selected layers,
// and remove the vectorLayer itself if selected.
tempSelLayers = tempSelLayers.filter(layer => {
if (layer instanceof VectorLayer) {
return false;
}
let p = LayerUtil.findParent(vl, layer.id);
while (p) {
if (_.find(tempSelLayers, l => l.id === p.id)) {
return false;
}
p = LayerUtil.findParent(vl, p.id);
}
return true;
});
if (!tempSelLayers.length) {
return;
}
// Find destination parent and insertion point.
const firstSelectedLayerParent = LayerUtil.findParent(vl, tempSelLayers[0].id).clone();
const firstSelectedLayerIndexInParent = _.findIndex(
firstSelectedLayerParent.children,
l => l.id === tempSelLayers[0].id,
);
// Remove all selected items from their parents and move them into a new parent.
const newGroup = new GroupLayer({
name: LayerUtil.getUniqueLayerName([vl], 'group'),
children: tempSelLayers,
});
const parentChildren = [...firstSelectedLayerParent.children];
parentChildren.splice(firstSelectedLayerIndexInParent, 0, newGroup);
_.remove(parentChildren, child =>
_.find(tempSelLayers, selectedLayer => selectedLayer.id === child.id),
);
firstSelectedLayerParent.children = parentChildren;
vl = LayerUtil.updateLayer(vl, firstSelectedLayerParent);
selectedLayerIds = new Set([newGroup.id]);
} else {
// Ungroup selected groups layers.
const newSelectedLayers: Layer[] = [];
tempSelLayers.filter(layer => layer instanceof GroupLayer).forEach(groupLayer => {
// Move children into parent.
const parent = LayerUtil.findParent(vl, groupLayer.id).clone();
const indexInParent = Math.max(
0,
_.findIndex(parent.children, l => l.id === groupLayer.id),
);
const newChildren = [...parent.children];
newChildren.splice(indexInParent, 0, ...groupLayer.children);
parent.children = newChildren;
vl = LayerUtil.updateLayer(vl, parent);
newSelectedLayers.splice(0, 0, ...groupLayer.children);
// Delete the parent.
vl = LayerUtil.removeLayers(vl, groupLayer.id);
});
selectedLayerIds = new Set(newSelectedLayers.map(l => l.id));
}
this.store.dispatch(
new BatchAction(new SetVectorLayer(vl), new SetSelectedLayers(selectedLayerIds)),
);
}
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:87,代码来源:layertimeline.service.ts
注:本文中的app/model/layers.LayerUtil类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论