@@ -7,5 +7,5 @@ "use strict"; | ||
function simplifyArray(arr) { | ||
let retArr = [], len = arr.length, util = Util_1.Util, n, val; | ||
for (n = 0; n < len; n++) { | ||
val = arr[n]; | ||
const retArr = [], len = arr.length, util = Util_1.Util; | ||
for (let n = 0; n < len; n++) { | ||
let val = arr[n]; | ||
if (util._isNumber(val)) { | ||
@@ -12,0 +12,0 @@ val = Math.round(val * 1000) / 1000; |
import { Node } from './Node.js'; | ||
import { GetSet } from './types.js'; | ||
type EnforceString<T> = T extends string ? T : never; | ||
type Constructor = abstract new (...args: any) => any; | ||
type Attr<T extends Constructor> = EnforceString<keyof InstanceType<T>>; | ||
type AfterFunc<T extends Constructor> = (this: InstanceType<T>) => void; | ||
type ExtractGetSet<T> = T extends GetSet<infer U, any> ? U : never; | ||
type Value<T extends Constructor, U extends Attr<T>> = ExtractGetSet<InstanceType<T>[U]>; | ||
type ValidatorFunc<T> = (val: ExtractGetSet<T>, attr: string) => T; | ||
type ExtractComponents<T extends Constructor, U extends Attr<T>> = Value<T, U> extends Record<string, any> ? EnforceString<keyof Value<T, U>>[] : never; | ||
export declare const Factory: { | ||
addGetterSetter(constructor: any, attr: any, def?: any, validator?: any, after?: any): void; | ||
addGetter(constructor: any, attr: any, def?: any): void; | ||
addSetter(constructor: any, attr: any, validator?: any, after?: any): void; | ||
overWriteSetter(constructor: any, attr: any, validator?: any, after?: any): void; | ||
addComponentsGetterSetter(constructor: any, attr: string, components: Array<string>, validator?: Function, after?: Function): void; | ||
addOverloadedGetterSetter(constructor: any, attr: any): void; | ||
addDeprecatedGetterSetter(constructor: any, attr: any, def: any, validator: any): void; | ||
backCompat(constructor: any, methods: any): void; | ||
addGetterSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, def?: Value<T, U>, validator?: ValidatorFunc<Value<T, U>>, after?: AfterFunc<T>): void; | ||
addGetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, def?: Value<T, U>): void; | ||
addSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, validator?: ValidatorFunc<Value<T, U>>, after?: AfterFunc<T>): void; | ||
overWriteSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, validator?: ValidatorFunc<Value<T, U>>, after?: AfterFunc<T>): void; | ||
addComponentsGetterSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, components: ExtractComponents<T, U>, validator?: ValidatorFunc<Value<T, U>>, after?: AfterFunc<T>): void; | ||
addOverloadedGetterSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U): void; | ||
addDeprecatedGetterSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, def: Value<T, U>, validator: ValidatorFunc<Value<T, U>>): void; | ||
backCompat<T extends Constructor>(constructor: T, methods: Record<string, string>): void; | ||
afterSetFilter(this: Node): void; | ||
}; | ||
export {}; |
@@ -6,3 +6,4 @@ "use strict"; | ||
const Validators_1 = require("./Validators"); | ||
const GET = 'get', SET = 'set'; | ||
const GET = 'get'; | ||
const SET = 'set'; | ||
exports.Factory = { | ||
@@ -15,3 +16,3 @@ addGetterSetter(constructor, attr, def, validator, after) { | ||
addGetter(constructor, attr, def) { | ||
const method = GET + Util_1.Util._capitalize(attr); | ||
var method = GET + Util_1.Util._capitalize(attr); | ||
constructor.prototype[method] = | ||
@@ -25,3 +26,3 @@ constructor.prototype[method] || | ||
addSetter(constructor, attr, validator, after) { | ||
const method = SET + Util_1.Util._capitalize(attr); | ||
var method = SET + Util_1.Util._capitalize(attr); | ||
if (!constructor.prototype[method]) { | ||
@@ -32,3 +33,3 @@ exports.Factory.overWriteSetter(constructor, attr, validator, after); | ||
overWriteSetter(constructor, attr, validator, after) { | ||
const method = SET + Util_1.Util._capitalize(attr); | ||
var method = SET + Util_1.Util._capitalize(attr); | ||
constructor.prototype[method] = function (val) { | ||
@@ -46,7 +47,7 @@ if (validator && val !== undefined && val !== null) { | ||
addComponentsGetterSetter(constructor, attr, components, validator, after) { | ||
let len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr), n, component; | ||
const len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr); | ||
constructor.prototype[getter] = function () { | ||
const ret = {}; | ||
for (n = 0; n < len; n++) { | ||
component = components[n]; | ||
for (let n = 0; n < len; n++) { | ||
const component = components[n]; | ||
ret[component] = this.getAttr(attr + capitalize(component)); | ||
@@ -58,5 +59,5 @@ } | ||
constructor.prototype[setter] = function (val) { | ||
let oldVal = this.attrs[attr], key; | ||
const oldVal = this.attrs[attr]; | ||
if (validator) { | ||
val = validator.call(this, val); | ||
val = validator.call(this, val, attr); | ||
} | ||
@@ -66,3 +67,3 @@ if (basicValidator) { | ||
} | ||
for (key in val) { | ||
for (const key in val) { | ||
if (!val.hasOwnProperty(key)) { | ||
@@ -87,3 +88,3 @@ continue; | ||
addOverloadedGetterSetter(constructor, attr) { | ||
const capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr; | ||
var capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr; | ||
constructor.prototype[attr] = function () { | ||
@@ -90,0 +91,0 @@ if (arguments.length) { |
@@ -52,3 +52,4 @@ "use strict"; | ||
let x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs; | ||
let div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), stackEnd = null, stack = stackStart, stackIn = null, stackOut = null, mul_sum = mul_table[radius], shg_sum = shg_table[radius]; | ||
const div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), mul_sum = mul_table[radius], shg_sum = shg_table[radius]; | ||
let stackEnd = null, stack = stackStart, stackIn = null, stackOut = null; | ||
for (i = 1; i < div; i++) { | ||
@@ -55,0 +56,0 @@ stack = stack.next = new BlurStack(); |
@@ -8,4 +8,4 @@ "use strict"; | ||
const Brighten = function (imageData) { | ||
let brightness = this.brightness() * 255, data = imageData.data, len = data.length, i; | ||
for (i = 0; i < len; i += 4) { | ||
const brightness = this.brightness() * 255, data = imageData.data, len = data.length; | ||
for (let i = 0; i < len; i += 4) { | ||
data[i] += brightness; | ||
@@ -12,0 +12,0 @@ data[i + 1] += brightness; |
@@ -9,4 +9,5 @@ "use strict"; | ||
const adjust = Math.pow((this.contrast() + 100) / 100, 2); | ||
let data = imageData.data, nPixels = data.length, red = 150, green = 150, blue = 150, i; | ||
for (i = 0; i < nPixels; i += 4) { | ||
const data = imageData.data, nPixels = data.length; | ||
let red = 150, green = 150, blue = 150; | ||
for (let i = 0; i < nPixels; i += 4) { | ||
red = data[i]; | ||
@@ -13,0 +14,0 @@ green = data[i + 1]; |
@@ -9,3 +9,4 @@ "use strict"; | ||
const Emboss = function (imageData) { | ||
let strength = this.embossStrength() * 10, greyLevel = this.embossWhiteLevel() * 255, direction = this.embossDirection(), blend = this.embossBlend(), dirY = 0, dirX = 0, data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4, y = h; | ||
const strength = this.embossStrength() * 10, greyLevel = this.embossWhiteLevel() * 255, direction = this.embossDirection(), blend = this.embossBlend(), data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4; | ||
let dirY = 0, dirX = 0, y = h; | ||
switch (direction) { | ||
@@ -106,3 +107,3 @@ case 'top-left': | ||
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossWhiteLevel', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter); | ||
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossDirection', 'top-left', null, Factory_1.Factory.afterSetFilter); | ||
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossBlend', false, null, Factory_1.Factory.afterSetFilter); | ||
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossDirection', 'top-left', undefined, Factory_1.Factory.afterSetFilter); | ||
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossBlend', false, undefined, Factory_1.Factory.afterSetFilter); |
@@ -8,3 +8,3 @@ "use strict"; | ||
function remap(fromValue, fromMin, fromMax, toMin, toMax) { | ||
let fromRange = fromMax - fromMin, toRange = toMax - toMin, toValue; | ||
const fromRange = fromMax - fromMin, toRange = toMax - toMin; | ||
if (fromRange === 0) { | ||
@@ -16,3 +16,3 @@ return toMin + toRange / 2; | ||
} | ||
toValue = (fromValue - fromMin) / fromRange; | ||
let toValue = (fromValue - fromMin) / fromRange; | ||
toValue = toRange * toValue + toMin; | ||
@@ -22,3 +22,4 @@ return toValue; | ||
const Enhance = function (imageData) { | ||
let data = imageData.data, nSubPixels = data.length, rMin = data[0], rMax = rMin, r, gMin = data[1], gMax = gMin, g, bMin = data[2], bMax = bMin, b, i; | ||
const data = imageData.data, nSubPixels = data.length; | ||
let rMin = data[0], rMax = rMin, r, gMin = data[1], gMax = gMin, g, bMin = data[2], bMax = bMin, b; | ||
const enhanceAmount = this.enhance(); | ||
@@ -28,3 +29,3 @@ if (enhanceAmount === 0) { | ||
} | ||
for (i = 0; i < nSubPixels; i += 4) { | ||
for (let i = 0; i < nSubPixels; i += 4) { | ||
r = data[i + 0]; | ||
@@ -84,3 +85,3 @@ if (r < rMin) { | ||
} | ||
for (i = 0; i < nSubPixels; i += 4) { | ||
for (let i = 0; i < nSubPixels; i += 4) { | ||
data[i + 0] = remap(data[i + 0], rMin, rMax, rGoalMin, rGoalMax); | ||
@@ -87,0 +88,0 @@ data[i + 1] = remap(data[i + 1], gMin, gMax, gGoalMin, gGoalMax); |
@@ -5,5 +5,5 @@ "use strict"; | ||
const Grayscale = function (imageData) { | ||
let data = imageData.data, len = data.length, i, brightness; | ||
for (i = 0; i < len; i += 4) { | ||
brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]; | ||
const data = imageData.data, len = data.length; | ||
for (let i = 0; i < len; i += 4) { | ||
const brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]; | ||
data[i] = brightness; | ||
@@ -10,0 +10,0 @@ data[i + 1] = brightness; |
@@ -11,3 +11,3 @@ "use strict"; | ||
const HSL = function (imageData) { | ||
let data = imageData.data, nPixels = data.length, v = 1, s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, l = this.luminance() * 127, i; | ||
const data = imageData.data, nPixels = data.length, v = 1, s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, l = this.luminance() * 127; | ||
const vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180); | ||
@@ -18,3 +18,3 @@ const rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw; | ||
let r, g, b, a; | ||
for (i = 0; i < nPixels; i += 4) { | ||
for (let i = 0; i < nPixels; i += 4) { | ||
r = data[i + 0]; | ||
@@ -21,0 +21,0 @@ g = data[i + 1]; |
@@ -5,4 +5,4 @@ "use strict"; | ||
const Invert = function (imageData) { | ||
let data = imageData.data, len = data.length, i; | ||
for (i = 0; i < len; i += 4) { | ||
const data = imageData.data, len = data.length; | ||
for (let i = 0; i < len; i += 4) { | ||
data[i] = 255 - data[i]; | ||
@@ -9,0 +9,0 @@ data[i + 1] = 255 - data[i + 1]; |
@@ -9,21 +9,21 @@ "use strict"; | ||
const ToPolar = function (src, dst, opt) { | ||
let srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, r = 0, g = 0, b = 0, a = 0; | ||
let rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid); | ||
x = xSize - xMid; | ||
y = ySize - yMid; | ||
rad = Math.sqrt(x * x + y * y); | ||
const srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2; | ||
let rMax = Math.sqrt(xMid * xMid + yMid * yMid); | ||
let x = xSize - xMid; | ||
let y = ySize - yMid; | ||
const rad = Math.sqrt(x * x + y * y); | ||
rMax = rad > rMax ? rad : rMax; | ||
let rSize = ySize, tSize = xSize, radius, theta; | ||
let conversion = ((360 / tSize) * Math.PI) / 180, sin, cos; | ||
for (theta = 0; theta < tSize; theta += 1) { | ||
sin = Math.sin(theta * conversion); | ||
cos = Math.cos(theta * conversion); | ||
for (radius = 0; radius < rSize; radius += 1) { | ||
const rSize = ySize, tSize = xSize; | ||
const conversion = ((360 / tSize) * Math.PI) / 180; | ||
for (let theta = 0; theta < tSize; theta += 1) { | ||
const sin = Math.sin(theta * conversion); | ||
const cos = Math.cos(theta * conversion); | ||
for (let radius = 0; radius < rSize; radius += 1) { | ||
x = Math.floor(xMid + ((rMax * radius) / rSize) * cos); | ||
y = Math.floor(yMid + ((rMax * radius) / rSize) * sin); | ||
i = (y * xSize + x) * 4; | ||
r = srcPixels[i + 0]; | ||
g = srcPixels[i + 1]; | ||
b = srcPixels[i + 2]; | ||
a = srcPixels[i + 3]; | ||
let i = (y * xSize + x) * 4; | ||
const r = srcPixels[i + 0]; | ||
const g = srcPixels[i + 1]; | ||
const b = srcPixels[i + 2]; | ||
const a = srcPixels[i + 3]; | ||
i = (theta + radius * xSize) * 4; | ||
@@ -38,24 +38,24 @@ dstPixels[i + 0] = r; | ||
const FromPolar = function (src, dst, opt) { | ||
let srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2, i, x, y, dx, dy, r = 0, g = 0, b = 0, a = 0; | ||
let rad, rMax = Math.sqrt(xMid * xMid + yMid * yMid); | ||
x = xSize - xMid; | ||
y = ySize - yMid; | ||
rad = Math.sqrt(x * x + y * y); | ||
const srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2; | ||
let rMax = Math.sqrt(xMid * xMid + yMid * yMid); | ||
let x = xSize - xMid; | ||
let y = ySize - yMid; | ||
const rad = Math.sqrt(x * x + y * y); | ||
rMax = rad > rMax ? rad : rMax; | ||
let rSize = ySize, tSize = xSize, radius, theta, phaseShift = opt.polarRotation || 0; | ||
const rSize = ySize, tSize = xSize, phaseShift = opt.polarRotation || 0; | ||
let x1, y1; | ||
for (x = 0; x < xSize; x += 1) { | ||
for (y = 0; y < ySize; y += 1) { | ||
dx = x - xMid; | ||
dy = y - yMid; | ||
radius = (Math.sqrt(dx * dx + dy * dy) * rSize) / rMax; | ||
theta = ((Math.atan2(dy, dx) * 180) / Math.PI + 360 + phaseShift) % 360; | ||
const dx = x - xMid; | ||
const dy = y - yMid; | ||
const radius = (Math.sqrt(dx * dx + dy * dy) * rSize) / rMax; | ||
let theta = ((Math.atan2(dy, dx) * 180) / Math.PI + 360 + phaseShift) % 360; | ||
theta = (theta * tSize) / 360; | ||
x1 = Math.floor(theta); | ||
y1 = Math.floor(radius); | ||
i = (y1 * xSize + x1) * 4; | ||
r = srcPixels[i + 0]; | ||
g = srcPixels[i + 1]; | ||
b = srcPixels[i + 2]; | ||
a = srcPixels[i + 3]; | ||
let i = (y1 * xSize + x1) * 4; | ||
const r = srcPixels[i + 0]; | ||
const g = srcPixels[i + 1]; | ||
const b = srcPixels[i + 2]; | ||
const a = srcPixels[i + 3]; | ||
i = (y * xSize + x) * 4; | ||
@@ -62,0 +62,0 @@ dstPixels[i + 0] = r; |
@@ -134,3 +134,4 @@ "use strict"; | ||
const Mask = function (imageData) { | ||
let threshold = this.threshold(), mask = backgroundMask(imageData, threshold); | ||
const threshold = this.threshold(); | ||
let mask = backgroundMask(imageData, threshold); | ||
if (mask) { | ||
@@ -137,0 +138,0 @@ mask = erodeMask(mask, imageData.width, imageData.height); |
@@ -8,4 +8,4 @@ "use strict"; | ||
const Posterize = function (imageData) { | ||
let levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels, i; | ||
for (i = 0; i < len; i += 1) { | ||
const levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels; | ||
for (let i = 0; i < len; i += 1) { | ||
data[i] = Math.floor(data[i] / scale) * scale; | ||
@@ -12,0 +12,0 @@ } |
@@ -8,6 +8,5 @@ "use strict"; | ||
const RGB = function (imageData) { | ||
let data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), i, brightness; | ||
for (i = 0; i < nPixels; i += 4) { | ||
brightness = | ||
(0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]) / 255; | ||
const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(); | ||
for (let i = 0; i < nPixels; i += 4) { | ||
const brightness = (0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]) / 255; | ||
data[i] = brightness * red; | ||
@@ -14,0 +13,0 @@ data[i + 1] = brightness * green; |
@@ -5,7 +5,7 @@ "use strict"; | ||
const Sepia = function (imageData) { | ||
let data = imageData.data, nPixels = data.length, i, r, g, b; | ||
for (i = 0; i < nPixels; i += 4) { | ||
r = data[i + 0]; | ||
g = data[i + 1]; | ||
b = data[i + 2]; | ||
const data = imageData.data, nPixels = data.length; | ||
for (let i = 0; i < nPixels; i += 4) { | ||
const r = data[i + 0]; | ||
const g = data[i + 1]; | ||
const b = data[i + 2]; | ||
data[i + 0] = Math.min(255, r * 0.393 + g * 0.769 + b * 0.189); | ||
@@ -12,0 +12,0 @@ data[i + 1] = Math.min(255, r * 0.349 + g * 0.686 + b * 0.168); |
@@ -19,3 +19,3 @@ "use strict"; | ||
_global: exports.glob, | ||
version: '9.3.16', | ||
version: '9.3.17', | ||
isBrowser: detectBrowser(), | ||
@@ -22,0 +22,0 @@ isUnminified: /param/.test(function (param) { }.toString()), |
@@ -313,3 +313,3 @@ import { Transform } from './Util.js'; | ||
zIndex: GetSet<number, this>; | ||
scale: GetSet<Vector2d | undefined, this>; | ||
scale: GetSet<Vector2d, this>; | ||
scaleX: GetSet<number, this>; | ||
@@ -316,0 +316,0 @@ scaleY: GetSet<number, this>; |
@@ -1413,3 +1413,3 @@ "use strict"; | ||
addGetterSetter(Node, 'offsetY', 0, (0, Validators_1.getNumberValidator)()); | ||
addGetterSetter(Node, 'dragDistance', null, (0, Validators_1.getNumberValidator)()); | ||
addGetterSetter(Node, 'dragDistance', undefined, (0, Validators_1.getNumberValidator)()); | ||
addGetterSetter(Node, 'width', 0, (0, Validators_1.getNumberValidator)()); | ||
@@ -1419,3 +1419,3 @@ addGetterSetter(Node, 'height', 0, (0, Validators_1.getNumberValidator)()); | ||
addGetterSetter(Node, 'preventDefault', true, (0, Validators_1.getBooleanValidator)()); | ||
addGetterSetter(Node, 'filters', null, function (val) { | ||
addGetterSetter(Node, 'filters', undefined, function (val) { | ||
this._filterUpToDate = false; | ||
@@ -1422,0 +1422,0 @@ return val; |
@@ -188,2 +188,7 @@ import { Node, NodeConfig } from './Node.js'; | ||
strokeLinearGradientColorStops: GetSet<Array<number | string>, this>; | ||
strokeLinearGradientStartPointX: GetSet<number, this>; | ||
strokeLinearGradientStartPointY: GetSet<number, this>; | ||
strokeLinearGradientEndPointX: GetSet<number, this>; | ||
strokeLinearGradientEndPointY: GetSet<number, this>; | ||
fillRule: GetSet<CanvasFillRule, this>; | ||
} |
@@ -405,12 +405,12 @@ "use strict"; | ||
drawHitFromCache(alphaThreshold = 0) { | ||
let cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight(), hitImageData, hitData, len, rgbColorKey, i, alpha; | ||
const cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight(); | ||
hitContext.clear(); | ||
hitContext.drawImage(sceneCanvas._canvas, 0, 0, hitWidth, hitHeight); | ||
try { | ||
hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight); | ||
hitData = hitImageData.data; | ||
len = hitData.length; | ||
rgbColorKey = Util_1.Util._hexToRgb(this.colorKey); | ||
for (i = 0; i < len; i += 4) { | ||
alpha = hitData[i + 3]; | ||
const hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight); | ||
const hitData = hitImageData.data; | ||
const len = hitData.length; | ||
const rgbColorKey = Util_1.Util._hexToRgb(this.colorKey); | ||
for (let i = 0; i < len; i += 4) { | ||
const alpha = hitData[i + 3]; | ||
if (alpha > alphaThreshold) { | ||
@@ -417,0 +417,0 @@ hitData[i] = rgbColorKey.r; |
@@ -90,5 +90,5 @@ "use strict"; | ||
return { | ||
x: lineRect.x - offset, | ||
x: lineRect.x, | ||
y: lineRect.y - offset, | ||
width: lineRect.width + offset * 2, | ||
width: lineRect.width, | ||
height: lineRect.height + offset * 2, | ||
@@ -95,0 +95,0 @@ }; |
@@ -9,2 +9,3 @@ import { Shape, ShapeConfig } from '../Shape.js'; | ||
} | ||
declare const NONE = "none"; | ||
export declare class Label extends Group { | ||
@@ -33,3 +34,3 @@ constructor(config?: LabelConfig); | ||
}; | ||
pointerDirection: GetSet<'left' | 'top' | 'right' | 'bottom' | 'up' | 'down', this>; | ||
pointerDirection: GetSet<'left' | 'up' | 'right' | 'down' | typeof NONE, this>; | ||
pointerWidth: GetSet<number, this>; | ||
@@ -39,1 +40,2 @@ pointerHeight: GetSet<number, this>; | ||
} | ||
export {}; |
@@ -13,4 +13,9 @@ "use strict"; | ||
return [...string].reduce((acc, char, index, array) => { | ||
if (/\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?(?:\u200D\p{Emoji_Presentation})+/u.test(char)) { | ||
acc.push(char); | ||
if (/\p{Emoji}/u.test(char)) { | ||
if (acc.length > 0 && /\p{Emoji}/u.test(acc[acc.length - 1])) { | ||
acc[acc.length - 1] += char; | ||
} | ||
else { | ||
acc.push(char); | ||
} | ||
} | ||
@@ -164,5 +169,3 @@ else if (/\p{Regional_Indicator}{2}/u.test(char + (array[index + 1] || ''))) { | ||
lineWidth = | ||
align === JUSTIFY && lastLine && !oneWord | ||
? totalWidth - padding * 2 | ||
: width; | ||
align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width; | ||
context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY + yOffset); | ||
@@ -286,4 +289,3 @@ context.lineWidth = fontSize / 15; | ||
const length = text.length; | ||
return (getDummyContext().measureText(text).width + | ||
(length ? letterSpacing * (length - 1) : 0)); | ||
return getDummyContext().measureText(text).width + letterSpacing * length; | ||
} | ||
@@ -294,3 +296,5 @@ _setTextData() { | ||
getDummyContext().font = this._getContextFont(); | ||
const additionalWidth = shouldAddEllipsis ? this._getTextWidth(ELLIPSIS) : 0; | ||
const additionalWidth = shouldAddEllipsis | ||
? this._getTextWidth(ELLIPSIS) | ||
: 0; | ||
for (let i = 0, max = lines.length; i < max; ++i) { | ||
@@ -297,0 +301,0 @@ let line = lines[i]; |
@@ -240,3 +240,3 @@ "use strict"; | ||
Factory_1.Factory.addGetterSetter(TextPath, 'text', EMPTY_STRING); | ||
Factory_1.Factory.addGetterSetter(TextPath, 'textDecoration', null); | ||
Factory_1.Factory.addGetterSetter(TextPath, 'kerningFunc', null); | ||
Factory_1.Factory.addGetterSetter(TextPath, 'textDecoration', ''); | ||
Factory_1.Factory.addGetterSetter(TextPath, 'kerningFunc', undefined); |
@@ -996,4 +996,4 @@ "use strict"; | ||
Factory_1.Factory.addGetterSetter(Transformer, 'padding', 0, (0, Validators_1.getNumberValidator)()); | ||
Factory_1.Factory.addGetterSetter(Transformer, 'nodes'); | ||
Factory_1.Factory.addGetterSetter(Transformer, 'node'); | ||
Factory_1.Factory.addGetterSetter(Transformer, 'nodes'); | ||
Factory_1.Factory.addGetterSetter(Transformer, 'boundBoxFunc'); | ||
@@ -1000,0 +1000,0 @@ Factory_1.Factory.addGetterSetter(Transformer, 'anchorDragBoundFunc'); |
@@ -161,4 +161,4 @@ "use strict"; | ||
clear() { | ||
let layers = this.children, len = layers.length, n; | ||
for (n = 0; n < len; n++) { | ||
const layers = this.children, len = layers.length; | ||
for (let n = 0; n < len; n++) { | ||
layers[n].clear(); | ||
@@ -241,4 +241,4 @@ } | ||
} | ||
let layers = this.children, len = layers.length, end = len - 1, n; | ||
for (n = end; n >= 0; n--) { | ||
const layers = this.children, len = layers.length, end = len - 1; | ||
for (let n = end; n >= 0; n--) { | ||
const shape = layers[n].getIntersection(pos); | ||
@@ -556,3 +556,3 @@ if (shape) { | ||
Global_1.Konva['_' + eventType + 'ListenClick'] = false; | ||
if (evt.cancelable && eventType !== 'touch') { | ||
if (evt.cancelable && eventType !== 'touch' && eventType !== 'pointer') { | ||
evt.preventDefault(); | ||
@@ -602,3 +602,4 @@ } | ||
setPointersPositions(evt) { | ||
let contentPosition = this._getContentPosition(), x = null, y = null; | ||
const contentPosition = this._getContentPosition(); | ||
let x = null, y = null; | ||
evt = evt ? evt : window.event; | ||
@@ -605,0 +606,0 @@ if (evt.touches !== undefined) { |
@@ -8,3 +8,3 @@ "use strict"; | ||
const Global_1 = require("./Global"); | ||
let blacklist = { | ||
const blacklist = { | ||
node: 1, | ||
@@ -15,3 +15,4 @@ duration: 1, | ||
yoyo: 1, | ||
}, PAUSED = 1, PLAYING = 2, REVERSING = 3, idCounter = 0, colorAttrs = ['fill', 'stroke', 'shadowColor']; | ||
}, PAUSED = 1, PLAYING = 2, REVERSING = 3, colorAttrs = ['fill', 'stroke', 'shadowColor']; | ||
let idCounter = 0; | ||
class TweenEngine { | ||
@@ -133,3 +134,4 @@ constructor(prop, propFunc, func, begin, finish, duration, yoyo) { | ||
constructor(config) { | ||
let that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || exports.Easings.Linear, yoyo = !!config.yoyo, key; | ||
const that = this, node = config.node, nodeId = node._id, easing = config.easing || exports.Easings.Linear, yoyo = !!config.yoyo; | ||
let duration, key; | ||
if (typeof config.duration === 'undefined') { | ||
@@ -178,8 +180,9 @@ duration = 0.3; | ||
_addAttr(key, end) { | ||
let node = this.node, nodeId = node._id, start, diff, tweenId, n, len, trueEnd, trueStart, endRGBA; | ||
tweenId = Tween.tweens[nodeId][key]; | ||
const node = this.node, nodeId = node._id; | ||
let diff, len, trueEnd, trueStart, endRGBA; | ||
const tweenId = Tween.tweens[nodeId][key]; | ||
if (tweenId) { | ||
delete Tween.attrs[nodeId][tweenId][key]; | ||
} | ||
start = node.getAttr(key); | ||
let start = node.getAttr(key); | ||
if (Util_1.Util._isArray(end)) { | ||
@@ -199,3 +202,3 @@ diff = []; | ||
if (key.indexOf('fill') === 0) { | ||
for (n = 0; n < len; n++) { | ||
for (let n = 0; n < len; n++) { | ||
if (n % 2 === 0) { | ||
@@ -218,3 +221,3 @@ diff.push(end[n] - start[n]); | ||
else { | ||
for (n = 0; n < len; n++) { | ||
for (let n = 0; n < len; n++) { | ||
diff.push(end[n] - start[n]); | ||
@@ -247,3 +250,4 @@ } | ||
_tweenFunc(i) { | ||
let node = this.node, attrs = Tween.attrs[node._id][this._id], key, attr, start, diff, newVal, n, len, end; | ||
const node = this.node, attrs = Tween.attrs[node._id][this._id]; | ||
let key, attr, start, diff, newVal, n, len, end; | ||
for (key in attrs) { | ||
@@ -360,5 +364,5 @@ attr = attrs[key]; | ||
destroy() { | ||
let nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId], key; | ||
const nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId]; | ||
this.pause(); | ||
for (key in attrs) { | ||
for (const key in attrs) { | ||
delete Tween.tweens[nodeId][key]; | ||
@@ -365,0 +369,0 @@ } |
@@ -153,3 +153,3 @@ "use strict"; | ||
exports.Transform = Transform; | ||
let OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = { | ||
const OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = { | ||
aliceblue: [240, 248, 255], | ||
@@ -304,3 +304,4 @@ antiquewhite: [250, 235, 215], | ||
yellowgreen: [154, 205, 5], | ||
}, RGB_REGEX = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/, animQueue = []; | ||
}, RGB_REGEX = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/; | ||
let animQueue = []; | ||
const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) || | ||
@@ -702,3 +703,3 @@ function (f) { | ||
_prepareArrayForTween(startArray, endArray, isClosed) { | ||
let n, start = [], end = []; | ||
const start = [], end = []; | ||
if (startArray.length > endArray.length) { | ||
@@ -709,3 +710,3 @@ const temp = endArray; | ||
} | ||
for (n = 0; n < startArray.length; n += 2) { | ||
for (let n = 0; n < startArray.length; n += 2) { | ||
start.push({ | ||
@@ -716,3 +717,3 @@ x: startArray[n], | ||
} | ||
for (n = 0; n < endArray.length; n += 2) { | ||
for (let n = 0; n < endArray.length; n += 2) { | ||
end.push({ | ||
@@ -719,0 +720,0 @@ x: endArray[n], |
export declare function RGBComponent(val: number): number; | ||
export declare function alphaComponent(val: number): number; | ||
export declare function getNumberValidator(): (<T>(val: T, attr: string) => T | void) | undefined; | ||
export declare function getNumberOrArrayOfNumbersValidator(noOfElements: number): (<T>(val: T, attr: string) => T | void) | undefined; | ||
export declare function getNumberOrAutoValidator(): (<T extends string>(val: T, attr: string) => T | void) | undefined; | ||
export declare function getStringValidator(): ((val: any, attr: string) => any) | undefined; | ||
export declare function getStringOrGradientValidator(): ((val: any, attr: string) => any) | undefined; | ||
export declare function getFunctionValidator(): ((val: any, attr: string) => any) | undefined; | ||
export declare function getNumberArrayValidator(): ((val: any, attr: string) => any) | undefined; | ||
export declare function getBooleanValidator(): ((val: any, attr: string) => any) | undefined; | ||
export declare function getComponentValidator(components: any): ((val: any, attr: string) => any) | undefined; | ||
export declare function getNumberValidator<T>(): ((val: T, attr: string) => T) | undefined; | ||
export declare function getNumberOrArrayOfNumbersValidator<T>(noOfElements: number): ((val: T, attr: string) => T) | undefined; | ||
export declare function getNumberOrAutoValidator<T>(): ((val: T, attr: string) => T) | undefined; | ||
export declare function getStringValidator<T>(): ((val: T, attr: string) => T) | undefined; | ||
export declare function getStringOrGradientValidator<T>(): ((val: T, attr: string) => T) | undefined; | ||
export declare function getFunctionValidator<T>(): ((val: T, attr: string) => T) | undefined; | ||
export declare function getNumberArrayValidator<T>(): ((val: T, attr: string) => T) | undefined; | ||
export declare function getBooleanValidator<T>(): ((val: T, attr: string) => T) | undefined; | ||
export declare function getComponentValidator<T>(components: string[]): ((val: T, attr: string) => T) | undefined; |
@@ -62,4 +62,4 @@ "use strict"; | ||
return function (val, attr) { | ||
const isNumber = Util_1.Util._isNumber(val); | ||
const isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements; | ||
let isNumber = Util_1.Util._isNumber(val); | ||
let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements; | ||
if (!isNumber && !isValidArray) { | ||
@@ -80,4 +80,4 @@ Util_1.Util.warn(_formatValue(val) + | ||
return function (val, attr) { | ||
const isNumber = Util_1.Util._isNumber(val); | ||
const isAuto = val === 'auto'; | ||
var isNumber = Util_1.Util._isNumber(val); | ||
var isAuto = val === 'auto'; | ||
if (!(isNumber || isAuto)) { | ||
@@ -111,3 +111,3 @@ Util_1.Util.warn(_formatValue(val) + | ||
const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' || | ||
(val && val.addColorStop); | ||
(val && val['addColorStop']); | ||
if (!(isString || isGradient)) { | ||
@@ -167,3 +167,3 @@ Util_1.Util.warn(_formatValue(val) + | ||
return function (val, attr) { | ||
const isBool = val === true || val === false; | ||
var isBool = val === true || val === false; | ||
if (!isBool) { | ||
@@ -170,0 +170,0 @@ Util_1.Util.warn(_formatValue(val) + |
{ | ||
"name": "konva", | ||
"version": "9.3.16", | ||
"version": "9.3.17", | ||
"description": "HTML5 2d canvas library.", | ||
"author": "Anton Lavrenov", | ||
@@ -19,6 +20,6 @@ "files": [ | ||
"build": "npm run compile && cp ./src/index-types.d.ts ./lib && gulp build && node ./rename-imports.mjs", | ||
"test:import": "npm run build && node ./test/import-test.cjs &&node ./test/import-test.mjs", | ||
"test:import": "npm run build && node ./test/import-test.cjs && node ./test/import-test.mjs", | ||
"test": "npm run test:browser && npm run test:node", | ||
"test:build": "parcel build ./test/unit-tests.html --dist-dir ./test-build --target none --public-url ./ --no-source-maps", | ||
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security", | ||
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security -a no-sandbox", | ||
"test:watch": "rm -rf ./.parcel-cache && PARCEL_WORKERS=0 parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html", | ||
@@ -63,9 +64,9 @@ "test:node": "ts-mocha -r ./test/node-global-setup.mjs -p ./test/tsconfig.json test/unit/**/*.ts --exit && npm run test:import", | ||
"devDependencies": { | ||
"@parcel/transformer-image": "2.10.1", | ||
"@size-limit/preset-big-lib": "^11.0.1", | ||
"@types/mocha": "^10.0.6", | ||
"canvas": "^2.11.2", | ||
"chai": "4.3.10", | ||
"@parcel/transformer-image": "2.13.2", | ||
"@size-limit/preset-big-lib": "^11.1.6", | ||
"@types/mocha": "^10.0.10", | ||
"canvas": "^3.0.0-rc3", | ||
"chai": "5.1.2", | ||
"filehound": "^1.17.6", | ||
"gulp": "^4.0.2", | ||
"gulp": "^5.0.0", | ||
"gulp-concat": "^2.6.1", | ||
@@ -83,10 +84,10 @@ "gulp-connect": "^5.7.0", | ||
"mocha-headless-chrome": "^4.0.0", | ||
"parcel": "2.10.1", | ||
"parcel": "2.13.2", | ||
"process": "^0.11.10", | ||
"rollup": "^4.9.1", | ||
"rollup": "^4.28.1", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"size-limit": "^11.0.1", | ||
"size-limit": "^11.1.6", | ||
"ts-mocha": "^10.0.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.7.2" | ||
}, | ||
@@ -93,0 +94,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1414917
0.16%32773
0.15%