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,20 @@
import {
getDefaultCurveSegments,
} from '../common';
import {
createTypedArray,
} from '../helpers/arrays';
import poolFactory from './pool_factory';
const bezierLengthPool = (function () {
function create() {
return {
addedLength: 0,
percents: createTypedArray('float32', getDefaultCurveSegments()),
lengths: createTypedArray('float32', getDefaultCurveSegments()),
};
}
return poolFactory(8, create);
}());
export default bezierLengthPool;

View File

@@ -0,0 +1,13 @@
import {
createTypedArray,
} from '../helpers/arrays';
import poolFactory from './pool_factory';
const pointPool = (function () {
function create() {
return createTypedArray('float32', 2);
}
return poolFactory(8, create);
}());
export default pointPool;

View File

@@ -0,0 +1,44 @@
import {
createSizedArray,
} from '../helpers/arrays';
import pooling from './pooling';
const poolFactory = (function () {
return function (initialLength, _create, _release) {
var _length = 0;
var _maxLength = initialLength;
var pool = createSizedArray(_maxLength);
var ob = {
newElement: newElement,
release: release,
};
function newElement() {
var element;
if (_length) {
_length -= 1;
element = pool[_length];
} else {
element = _create();
}
return element;
}
function release(element) {
if (_length === _maxLength) {
pool = pooling.double(pool);
_maxLength *= 2;
}
if (_release) {
_release(element);
}
pool[_length] = element;
_length += 1;
}
return ob;
};
}());
export default poolFactory;

View File

@@ -0,0 +1,15 @@
import {
createSizedArray,
} from '../helpers/arrays';
const pooling = (function () {
function double(arr) {
return arr.concat(createSizedArray(arr.length));
}
return {
double: double,
};
}());
export default pooling;

View File

@@ -0,0 +1,24 @@
import bezierLengthPool from './bezier_length_pool';
import poolFactory from './pool_factory';
const segmentsLengthPool = (function () {
function create() {
return {
lengths: [],
totalLength: 0,
};
}
function release(element) {
var i;
var len = element.lengths.length;
for (i = 0; i < len; i += 1) {
bezierLengthPool.release(element.lengths[i]);
}
element.lengths.length = 0;
}
return poolFactory(8, create, release);
}());
export default segmentsLengthPool;

View File

@@ -0,0 +1,48 @@
import {
createSizedArray,
} from '../helpers/arrays';
import shapePool from './shape_pool';
import pooling from './pooling';
import ShapeCollection from '../shapes/ShapeCollection';
const shapeCollectionPool = (function () {
var ob = {
newShapeCollection: newShapeCollection,
release: release,
};
var _length = 0;
var _maxLength = 4;
var pool = createSizedArray(_maxLength);
function newShapeCollection() {
var shapeCollection;
if (_length) {
_length -= 1;
shapeCollection = pool[_length];
} else {
shapeCollection = new ShapeCollection();
}
return shapeCollection;
}
function release(shapeCollection) {
var i;
var len = shapeCollection._length;
for (i = 0; i < len; i += 1) {
shapePool.release(shapeCollection.shapes[i]);
}
shapeCollection._length = 0;
if (_length === _maxLength) {
pool = pooling.double(pool);
_maxLength *= 2;
}
pool[_length] = shapeCollection;
_length += 1;
}
return ob;
}());
export default shapeCollectionPool;

View File

@@ -0,0 +1,44 @@
import poolFactory from './pool_factory';
import pointPool from './point_pool';
import ShapePath from '../shapes/ShapePath';
const shapePool = (function () {
function create() {
return new ShapePath();
}
function release(shapePath) {
var len = shapePath._length;
var i;
for (i = 0; i < len; i += 1) {
pointPool.release(shapePath.v[i]);
pointPool.release(shapePath.i[i]);
pointPool.release(shapePath.o[i]);
shapePath.v[i] = null;
shapePath.i[i] = null;
shapePath.o[i] = null;
}
shapePath._length = 0;
shapePath.c = false;
}
function clone(shape) {
var cloned = factory.newElement();
var i;
var len = shape._length === undefined ? shape.v.length : shape._length;
cloned.setLength(len);
cloned.c = shape.c;
for (i = 0; i < len; i += 1) {
cloned.setTripleAt(shape.v[i][0], shape.v[i][1], shape.o[i][0], shape.o[i][1], shape.i[i][0], shape.i[i][1], i);
}
return cloned;
}
var factory = poolFactory(4, create, release);
factory.clone = clone;
return factory;
}());
export default shapePool;