本文整理匯總了TypeScript中app/model/layers.LayerUtil.getCanvasTransformForLayer方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LayerUtil.getCanvasTransformForLayer方法的具體用法?TypeScript LayerUtil.getCanvasTransformForLayer怎麽用?TypeScript LayerUtil.getCanvasTransformForLayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app/model/layers.LayerUtil
的用法示例。
在下文中一共展示了LayerUtil.getCanvasTransformForLayer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: conditionalAttr
(layer: VectorLayer | GroupLayer | PathLayer, parentNode: Node) => {
if (layer instanceof VectorLayer) {
if (withIds) {
conditionalAttr(destinationNode, 'id', vl.name, '');
}
conditionalAttr(destinationNode, 'opacity', vl.alpha, 1);
return parentNode;
}
if (layer instanceof PathLayer) {
const { pathData } = layer;
if (!pathData.getPathString()) {
return undefined;
}
const node = xmlDoc.createElement('path');
if (withIds) {
conditionalAttr(node, 'id', layer.name);
}
maybeSetClipPathForLayerFn(node, layer.id);
conditionalAttr(node, 'd', pathData.getPathString());
if (layer.fillColor) {
conditionalAttr(node, 'fill', ColorUtil.androidToCssHexColor(layer.fillColor), '');
} else {
conditionalAttr(node, 'fill', 'none');
}
conditionalAttr(node, 'fill-opacity', layer.fillAlpha, 1);
if (layer.strokeColor) {
conditionalAttr(node, 'stroke', ColorUtil.androidToCssHexColor(layer.strokeColor), '');
}
conditionalAttr(node, 'stroke-opacity', layer.strokeAlpha, 1);
conditionalAttr(node, 'stroke-width', layer.strokeWidth, 0);
if (layer.trimPathStart !== 0 || layer.trimPathEnd !== 1 || layer.trimPathOffset !== 0) {
const flattenedTransform = LayerUtil.getCanvasTransformForLayer(vl, layer.id);
const { a, d } = flattenedTransform;
// Note that we only return the length of the first sub path due to
// https://code.google.com/p/android/issues/detail?id=172547
let pathLength: number;
if (Math.abs(a) !== 1 || Math.abs(d) !== 1) {
// Then recompute the scaled path length.
pathLength = pathData
.mutate()
.transform(flattenedTransform)
.build()
.getSubPathLength(0);
} else {
pathLength = pathData.getSubPathLength(0);
}
const strokeDashArray = PathUtil.toStrokeDashArray(
layer.trimPathStart,
layer.trimPathEnd,
layer.trimPathOffset,
pathLength,
).join(',');
const strokeDashOffset = PathUtil.toStrokeDashOffset(
layer.trimPathStart,
layer.trimPathEnd,
layer.trimPathOffset,
pathLength,
).toString();
conditionalAttr(node, 'stroke-dasharray', strokeDashArray);
conditionalAttr(node, 'stroke-dashoffset', strokeDashOffset);
}
conditionalAttr(node, 'stroke-linecap', layer.strokeLinecap, 'butt');
conditionalAttr(node, 'stroke-linejoin', layer.strokeLinejoin, 'miter');
conditionalAttr(node, 'stroke-miterlimit', layer.strokeMiterLimit, 4);
const fillRule = !layer.fillType || layer.fillType === 'nonZero' ? 'nonzero' : 'evenodd';
conditionalAttr(node, 'fill-rule', fillRule, 'nonzero');
parentNode.appendChild(node);
return parentNode;
}
if (layer instanceof GroupLayer) {
const node = xmlDoc.createElement('g');
if (withIds) {
conditionalAttr(node, 'id', layer.name);
}
const transformValues: string[] = [];
if (layer.translateX || layer.translateY) {
transformValues.push(`translate(${layer.translateX} ${layer.translateY})`);
}
if (layer.rotation) {
transformValues.push(`rotate(${layer.rotation} ${layer.pivotX} ${layer.pivotY})`);
}
if (layer.scaleX !== 1 || layer.scaleY !== 1) {
if (layer.pivotX || layer.pivotY) {
transformValues.push(`translate(${layer.pivotX} ${layer.pivotY})`);
}
transformValues.push(`scale(${layer.scaleX} ${layer.scaleY})`);
if (layer.pivotX || layer.pivotY) {
transformValues.push(`translate(${-layer.pivotX} ${-layer.pivotY})`);
}
}
let nodeToAttachToParent = node;
if (transformValues.length) {
node.setAttributeNS(undefined, 'transform', transformValues.join(' '));
if (isLayerBeingClippedFn(layer.id)) {
// Create a wrapper node so that the clip-path is applied before the transformations.
const wrapperNode = xmlDoc.createElement('g');
wrapperNode.appendChild(node);
nodeToAttachToParent = wrapperNode;
//.........這裏部分代碼省略.........