|
|
|
@ -31,7 +31,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
*/
|
|
|
|
|
this.shapeKeyToItem = {};
|
|
|
|
|
|
|
|
|
|
// Caches operations in the form of 'operation:def1[:def2]'
|
|
|
|
|
// Caches operations in the form of 'operation/def1[/def2]'
|
|
|
|
|
/** @type {Object.<string, Array<ShapeDefinition>|ShapeDefinition>} */
|
|
|
|
|
this.operationCache = {};
|
|
|
|
|
}
|
|
|
|
@ -89,7 +89,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
* @returns {[ShapeDefinition, ShapeDefinition]}
|
|
|
|
|
*/
|
|
|
|
|
shapeActionCutHalf(definition) {
|
|
|
|
|
const key = "cut:" + definition.getHash();
|
|
|
|
|
const key = "cut/" + definition.getHash();
|
|
|
|
|
if (this.operationCache[key]) {
|
|
|
|
|
return /** @type {[ShapeDefinition, ShapeDefinition]} */ (this.operationCache[key]);
|
|
|
|
|
}
|
|
|
|
@ -108,7 +108,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
* @returns {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]}
|
|
|
|
|
*/
|
|
|
|
|
shapeActionCutQuad(definition) {
|
|
|
|
|
const key = "cut-quad:" + definition.getHash();
|
|
|
|
|
const key = "cut-quad/" + definition.getHash();
|
|
|
|
|
if (this.operationCache[key]) {
|
|
|
|
|
return /** @type {[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]} */ (this
|
|
|
|
|
.operationCache[key]);
|
|
|
|
@ -130,7 +130,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
* @returns {ShapeDefinition}
|
|
|
|
|
*/
|
|
|
|
|
shapeActionRotateCW(definition) {
|
|
|
|
|
const key = "rotate-cw:" + definition.getHash();
|
|
|
|
|
const key = "rotate-cw/" + definition.getHash();
|
|
|
|
|
if (this.operationCache[key]) {
|
|
|
|
|
return /** @type {ShapeDefinition} */ (this.operationCache[key]);
|
|
|
|
|
}
|
|
|
|
@ -148,7 +148,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
* @returns {ShapeDefinition}
|
|
|
|
|
*/
|
|
|
|
|
shapeActionRotateCCW(definition) {
|
|
|
|
|
const key = "rotate-ccw:" + definition.getHash();
|
|
|
|
|
const key = "rotate-ccw/" + definition.getHash();
|
|
|
|
|
if (this.operationCache[key]) {
|
|
|
|
|
return /** @type {ShapeDefinition} */ (this.operationCache[key]);
|
|
|
|
|
}
|
|
|
|
@ -166,7 +166,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
* @returns {ShapeDefinition}
|
|
|
|
|
*/
|
|
|
|
|
shapeActionRotate180(definition) {
|
|
|
|
|
const key = "rotate-fl:" + definition.getHash();
|
|
|
|
|
const key = "rotate-fl/" + definition.getHash();
|
|
|
|
|
if (this.operationCache[key]) {
|
|
|
|
|
return /** @type {ShapeDefinition} */ (this.operationCache[key]);
|
|
|
|
|
}
|
|
|
|
@ -185,7 +185,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
* @returns {ShapeDefinition}
|
|
|
|
|
*/
|
|
|
|
|
shapeActionStack(lowerDefinition, upperDefinition) {
|
|
|
|
|
const key = "stack:" + lowerDefinition.getHash() + ":" + upperDefinition.getHash();
|
|
|
|
|
const key = "stack/" + lowerDefinition.getHash() + "/" + upperDefinition.getHash();
|
|
|
|
|
if (this.operationCache[key]) {
|
|
|
|
|
return /** @type {ShapeDefinition} */ (this.operationCache[key]);
|
|
|
|
|
}
|
|
|
|
@ -202,7 +202,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
* @returns {ShapeDefinition}
|
|
|
|
|
*/
|
|
|
|
|
shapeActionPaintWith(definition, color) {
|
|
|
|
|
const key = "paint:" + definition.getHash() + ":" + color;
|
|
|
|
|
const key = "paint/" + definition.getHash() + "/" + color;
|
|
|
|
|
if (this.operationCache[key]) {
|
|
|
|
|
return /** @type {ShapeDefinition} */ (this.operationCache[key]);
|
|
|
|
|
}
|
|
|
|
@ -219,7 +219,7 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|
|
|
|
* @returns {ShapeDefinition}
|
|
|
|
|
*/
|
|
|
|
|
shapeActionPaintWith4Colors(definition, colors) {
|
|
|
|
|
const key = "paint4:" + definition.getHash() + ":" + colors.join(",");
|
|
|
|
|
const key = "paint4/" + definition.getHash() + "/" + colors.join(",");
|
|
|
|
|
if (this.operationCache[key]) {
|
|
|
|
|
return /** @type {ShapeDefinition} */ (this.operationCache[key]);
|
|
|
|
|
}
|
|
|
|
|