P.cleanControl = function (label) {
let capLabel = capitalize(label);
this[`dirty${capLabel}`] = false;
let pivotLabel = `${label}Pivot`,
pathLabel = `${label}Path`,
particleLabel = `${label}Particle`,
pivot = this[pivotLabel],
path = this[pathLabel],
part = this[particleLabel],
art, pathData;
if (pivot && pivot.substring) {
art = artefact[pivot];
if (art) pivot = art;
}
if (path && path.substring) {
art = artefact[path];
if (art) path = art;
}
if (part && part.substring) {
art = particle[part];
if (art) part = art;
}
let lock = this[`${label}LockTo`],
x, y, ox, oy, here, host, dims, flag,
raw = this[label],
current = this[`current${capLabel}`];
if (lock === 'pivot' && (!pivot || pivot.substring)) lock = 'coord';
else if (lock === 'path' && (!path || path.substring)) lock = 'coord';
else if (lock === 'particle' && (!part || part.substring)) lock = 'coord';
switch(lock) {
case 'pivot' :
if (this.pivotCorner && pivot.getCornerCoordinate) {
[x, y] = pivot.getCornerCoordinate(this[`${label}PivotCorner`]);
}
else [x, y] = pivot.currentStampPosition;
if (!this.addPivotOffset) {
[ox, oy] = pivot.currentOffset;
x -= ox;
y -= oy;
}
break;
case 'path' :
pathData = this.getControlPathData(path, label, capLabel);
x = pathData.x;
y = pathData.y;
if (!this.addPathOffset) {
x -= path.currentOffset[0];
y -= path.currentOffset[1];
}
break;
case 'particle' :
x = part.position.x;
y = part.position.y;
this.pathCalculatedOnce = false;
break;
case 'mouse' :
here = this.getHere();
x = here.x || 0;
y = here.y || 0;
break;
default :
x = y = 0;
host = this.getHost();
if (host) {
dims = host.currentDimensions;
if (dims) {
this.cleanPosition(current, raw, dims);
[x, y] = current;
}
}
}
current[0] = x;
current[1] = y;
this.dirtySpecies = true;
this.dirtyPathObject = true;
this.dirtyPositionSubscribers = true;
};