first commit

This commit is contained in:
becarta
2025-05-16 00:17:42 +02:00
parent ea5c866137
commit bacf566ec9
6020 changed files with 1715262 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
const createTypedArray = (function () {
function createRegularArray(type, len) {
var i = 0;
var arr = [];
var value;
switch (type) {
case 'int16':
case 'uint8c':
value = 1;
break;
default:
value = 1.1;
break;
}
for (i = 0; i < len; i += 1) {
arr.push(value);
}
return arr;
}
function createTypedArrayFactory(type, len) {
if (type === 'float32') {
return new Float32Array(len);
} if (type === 'int16') {
return new Int16Array(len);
} if (type === 'uint8c') {
return new Uint8ClampedArray(len);
}
return createRegularArray(type, len);
}
if (typeof Uint8ClampedArray === 'function' && typeof Float32Array === 'function') {
return createTypedArrayFactory;
}
return createRegularArray;
}());
function createSizedArray(len) {
return Array.apply(null, { length: len });
}
export {
createTypedArray,
createSizedArray,
};

View File

@@ -0,0 +1,96 @@
import createTag from './html_elements';
import createNS from './svg_elements';
import featureSupport from '../featureSupport';
var lumaLoader = (function () {
var id = '__lottie_element_luma_buffer';
var lumaBuffer = null;
var lumaBufferCtx = null;
var svg = null;
// This alternate solution has a slight delay before the filter is applied, resulting in a flicker on the first frame.
// Keeping this here for reference, and in the future, if offscreen canvas supports url filters, this can be used.
// For now, neither of them work for offscreen canvas, so canvas workers can't support the luma track matte mask.
// Naming it solution 2 to mark the extra comment lines.
/*
var svgString = [
'<svg xmlns="http://www.w3.org/2000/svg">',
'<filter id="' + id + '">',
'<feColorMatrix type="matrix" color-interpolation-filters="sRGB" values="',
'0.3, 0.3, 0.3, 0, 0, ',
'0.3, 0.3, 0.3, 0, 0, ',
'0.3, 0.3, 0.3, 0, 0, ',
'0.3, 0.3, 0.3, 0, 0',
'"/>',
'</filter>',
'</svg>',
].join('');
var blob = new Blob([svgString], { type: 'image/svg+xml' });
var url = URL.createObjectURL(blob);
*/
function createLumaSvgFilter() {
var _svg = createNS('svg');
var fil = createNS('filter');
var matrix = createNS('feColorMatrix');
fil.setAttribute('id', id);
matrix.setAttribute('type', 'matrix');
matrix.setAttribute('color-interpolation-filters', 'sRGB');
matrix.setAttribute('values', '0.3, 0.3, 0.3, 0, 0, 0.3, 0.3, 0.3, 0, 0, 0.3, 0.3, 0.3, 0, 0, 0.3, 0.3, 0.3, 0, 0');
fil.appendChild(matrix);
_svg.appendChild(fil);
_svg.setAttribute('id', id + '_svg');
if (featureSupport.svgLumaHidden) {
_svg.style.display = 'none';
}
return _svg;
}
function loadLuma() {
if (!lumaBuffer) {
svg = createLumaSvgFilter();
document.body.appendChild(svg);
lumaBuffer = createTag('canvas');
lumaBufferCtx = lumaBuffer.getContext('2d');
// lumaBufferCtx.filter = `url('${url}#__lottie_element_luma_buffer')`; // part of solution 2
lumaBufferCtx.filter = 'url(#' + id + ')';
lumaBufferCtx.fillStyle = 'rgba(0,0,0,0)';
lumaBufferCtx.fillRect(0, 0, 1, 1);
}
}
function getLuma(canvas) {
if (!lumaBuffer) {
loadLuma();
}
lumaBuffer.width = canvas.width;
lumaBuffer.height = canvas.height;
// lumaBufferCtx.filter = `url('${url}#__lottie_element_luma_buffer')`; // part of solution 2
lumaBufferCtx.filter = 'url(#' + id + ')';
return lumaBuffer;
}
return {
load: loadLuma,
get: getLuma,
};
});
function createCanvas(width, height) {
if (featureSupport.offscreenCanvas) {
return new OffscreenCanvas(width, height);
}
var canvas = createTag('canvas');
canvas.width = width;
canvas.height = height;
return canvas;
}
const assetLoader = (function () {
return {
loadLumaCanvas: lumaLoader.load,
getLumaCanvas: lumaLoader.get,
createCanvas: createCanvas,
};
}());
export default assetLoader;

View File

@@ -0,0 +1,26 @@
const getBlendMode = (function () {
var blendModeEnums = {
0: 'source-over',
1: 'multiply',
2: 'screen',
3: 'overlay',
4: 'darken',
5: 'lighten',
6: 'color-dodge',
7: 'color-burn',
8: 'hard-light',
9: 'soft-light',
10: 'difference',
11: 'exclusion',
12: 'hue',
13: 'saturation',
14: 'color',
15: 'luminosity',
};
return function (mode) {
return blendModeEnums[mode] || '';
};
}());
export default getBlendMode;

View File

@@ -0,0 +1,29 @@
function DynamicPropertyContainer() {}
DynamicPropertyContainer.prototype = {
addDynamicProperty: function (prop) {
if (this.dynamicProperties.indexOf(prop) === -1) {
this.dynamicProperties.push(prop);
this.container.addDynamicProperty(this);
this._isAnimated = true;
}
},
iterateDynamicProperties: function () {
this._mdf = false;
var i;
var len = this.dynamicProperties.length;
for (i = 0; i < len; i += 1) {
this.dynamicProperties[i].getValue();
if (this.dynamicProperties[i]._mdf) {
this._mdf = true;
}
}
},
initDynamicPropertyContainer: function (container) {
this.container = container;
this.dynamicProperties = [];
this._mdf = false;
this._isAnimated = false;
},
};
export default DynamicPropertyContainer;

View File

@@ -0,0 +1,3 @@
export default {
TRANSFORM_EFFECT: 'transformEFfect',
};

View File

@@ -0,0 +1,6 @@
function createTag(type) {
// return {appendChild:function(){},setAttribute:function(){},style:{}}
return document.createElement(type);
}
export default createTag;

View File

@@ -0,0 +1,3 @@
export default {
SHAPE: 'shape',
};

View File

@@ -0,0 +1,16 @@
const lineCapEnum = {
1: 'butt',
2: 'round',
3: 'square',
};
const lineJoinEnum = {
1: 'miter',
2: 'round',
3: 'bevel',
};
export {
lineCapEnum,
lineJoinEnum,
};

View File

@@ -0,0 +1,8 @@
import { svgNS } from '../../main';
function createNS(type) {
// return {appendChild:function(){},setAttribute:function(){},style:{}}
return document.createElementNS(svgNS, type);
}
export default createNS;