@nmmty/lazycanvas 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -141,7 +141,9 @@ class Path2DLayer extends BaseLayer_1.BaseLayer {
|
|
|
141
141
|
ctx.save();
|
|
142
142
|
let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle, { debug, manager });
|
|
143
143
|
(0, utils_1.transform)(ctx, this.props.transform, { width: 0, height: 0, x: 0, y: 0, type: this.type });
|
|
144
|
+
(0, utils_1.drawShadow)(ctx, this.props.shadow);
|
|
144
145
|
(0, utils_1.opacity)(ctx, this.props.opacity);
|
|
146
|
+
(0, utils_1.filters)(ctx, this.props.filter);
|
|
145
147
|
ctx.globalCompositeOperation = this.props.globalComposite;
|
|
146
148
|
if (this.props.clipPath) {
|
|
147
149
|
ctx.clip(this.props.path2D);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
|
|
2
|
-
import {
|
|
2
|
+
import { AnyTextAlign, AnyTextBaseline, AnyTextDirection, AnyWeight, ColorType, LayerType, LineCap, LineJoin, ScaleType, SubStringColor } from "../../types";
|
|
3
3
|
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
|
|
4
4
|
import { LayersManager } from "../managers";
|
|
5
5
|
/**
|
|
@@ -214,7 +214,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
|
|
|
214
214
|
ctx.textBaseline = this.props.baseline;
|
|
215
215
|
if (this.props.direction)
|
|
216
216
|
ctx.direction = this.props.direction;
|
|
217
|
-
let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle, { debug, layer: { width: w, height: h, x, y, align: '
|
|
217
|
+
let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle, { debug, layer: { width: w, height: h, x, y, align: 'center' }, manager });
|
|
218
218
|
if (this.props.multiline.enabled) {
|
|
219
219
|
const words = this.props.text.split(' ');
|
|
220
220
|
let lines = [];
|
|
@@ -128,14 +128,20 @@ class Gradient {
|
|
|
128
128
|
switch (gradientData.type) {
|
|
129
129
|
case types_1.GradientType.Linear:
|
|
130
130
|
case "linear":
|
|
131
|
-
if (gradientData.type === "linear" && (gradientData.angle || gradientData.angle === 0) && opts.layer) {
|
|
131
|
+
if (gradientData.type === "linear" && (gradientData.angle || gradientData.angle === 0) && opts.layer && gradientData.points.length < 2) {
|
|
132
132
|
const { width, height, x, y, align } = opts.layer;
|
|
133
133
|
const cx = this.getPosition(x, width, align, 'x');
|
|
134
134
|
const cy = this.getPosition(y, height, align, 'y');
|
|
135
|
+
if (opts.debug)
|
|
136
|
+
LazyUtil_1.LazyLog.log('none', `Center for angle calculation:`, { cx, cy });
|
|
135
137
|
const [p1, p2] = this.getLinearGradientPoints(cx, cy, width, height, gradientData.angle);
|
|
138
|
+
if (opts.debug)
|
|
139
|
+
LazyUtil_1.LazyLog.log('none', `Linear Gradient Points from angle:`, { p1, p2 });
|
|
136
140
|
gradient = ctx.createLinearGradient(p1.x, p1.y, p2.x, p2.y);
|
|
137
141
|
}
|
|
138
142
|
else {
|
|
143
|
+
if (opts.debug)
|
|
144
|
+
LazyUtil_1.LazyLog.log('none', `Linear Gradient created from points.`);
|
|
139
145
|
gradient = ctx.createLinearGradient(x0, y0, x1 || x0, y1 || y0);
|
|
140
146
|
}
|
|
141
147
|
break;
|