this.currentScale = 1;
const success = gradientEngine.action({
fixedGradientData: getFixedGradientData(grad, FILL),
identifier: fillId,
imageData: data,
entity: this,
matrix,
});
this.currentScale = tempScale;
if (success) {
this.identifierFillGradientCache = fillId;
this.dirtyFillGradient = false;
this.dirtyFillGradientCache = false;
this.dirtyFilterIdentifier = true;
}
else this.dirtyFillGradientCache = true;
releaseCell(myCell);
};
P.setLabelTextEngine = function (engine) {
const textStyle = this.defaultTextStyle;
engine.font = textStyle.canvasFont;
engine.fontKerning = textStyle.fontKerning;
engine.fontStretch = textStyle.fontStretch;
engine.fontVariantCaps = textStyle.fontVariantCaps;
engine.textRendering = textStyle.textRendering;
engine.letterSpacing = textStyle.letterSpacing;
engine.wordSpacing = textStyle.wordSpacing;
engine.direction = textStyle.direction;
engine.textAlign = LEFT;
engine.textBaseline = TOP;
engine.shadowOffsetX = 0;
engine.shadowOffsetY = 0;
engine.shadowBlur = 0;
engine.fillStyle = BLACK;
engine.strokeStyle = BLACK;
};
P.stampLabelDirect = function (engine, pos) {
const method = this.defaultTextStyle.method,
complexFill = this.useFillGradientCache,
textFillColor = this.getLabelTextFillColor();
if (
(!complexFill || !this.useTextStyleForOutline) &&
this.methodDrawsOutlineBeforeFill(method)
) {
this.drawLabelOutline(
engine,
pos,
this.useTextStyleForOutline ? textFillColor : null
);
}
if (method !== DRAW) {
engine.fillStyle = textFillColor;
engine.fillText(...pos);
}
};
P.stampLabelGradientFill = function (host) {
const identifier = this.identifierFillGradientCache;
if (!identifier) return;
const data = getWorkstoreItem(identifier);
if (data && data.w && data.h && data.imageData) {
const { x, y, w, h, imageData } = data;
const myCell = requestCell();
const {
element,
engine,
} = myCell;
element.width = w;
element.height = h;
engine.putImageData(imageData, 0, 0);
const hostEngine = host.engine;
hostEngine.save();
hostEngine.resetTransform();
hostEngine.drawImage(element, x, y);
hostEngine.restore();
releaseCell(myCell);
}
};
P.addUnderlineToGradientMask = function (targetCell, pos) {
const {
currentDimensions,
currentScale,
currentStampPosition,
defaultTextStyle,
fontVerticalOffset,
} = this;
const {
underlineGap,
underlineOffset,
underlineWidth,
} = defaultTextStyle;
const [, x, y] = pos;
const [localWidth, localHeight] = currentDimensions;
const underlineStartY = y + (underlineOffset * localHeight) - fontVerticalOffset * currentScale;
const underlineDepth = underlineWidth * currentScale;
const {
element: targetElement,
engine: targetEngine,
} = targetCell;
const mycell = requestCell(targetElement.width, targetElement.height);
const {
element,
engine,
} = mycell;
element.width = targetElement.width;
element.height = targetElement.height;
mycell.rotateDestination(engine, ...currentStampPosition, this);
engine.fillStyle = BLACK;
engine.strokeStyle = BLACK;
engine.font = defaultTextStyle.canvasFont;
engine.fontKerning = defaultTextStyle.fontKerning;
engine.fontStretch = defaultTextStyle.fontStretch;
engine.fontVariantCaps = defaultTextStyle.fontVariantCaps;
engine.textRendering = defaultTextStyle.textRendering;
engine.letterSpacing = defaultTextStyle.letterSpacing;
engine.lineCap = ROUND;
engine.lineJoin = ROUND;
engine.wordSpacing = defaultTextStyle.wordSpacing;
engine.direction = defaultTextStyle.direction;
engine.textAlign = LEFT;
engine.textBaseline = TOP;
engine.lineWidth = (underlineGap * 2) * currentScale;
this.setImageSmoothing(engine);
engine.strokeText(...pos);
engine.fillText(...pos);
engine.globalCompositeOperation = SOURCE_OUT;
engine.fillRect(x, underlineStartY, localWidth, underlineDepth);
targetEngine.save();
targetEngine.resetTransform();
targetEngine.globalCompositeOperation = SOURCE_OVER;
targetEngine.drawImage(element, 0, 0);
targetEngine.restore();
releaseCell(mycell);
};