tslint changes

This commit is contained in:
Jeremy Simpson
2019-08-30 01:52:40 -07:00
parent 7603879d35
commit 7f7efbb94b
446 changed files with 70650 additions and 70661 deletions
+59 -59
View File
@@ -4,73 +4,73 @@ import { createMat2D, copyMat2D, mulMat2D, rotateMat2D, scaleMat2D, translateMat
import { rect, copyRect } from '../common/rect';
interface SavedState {
globalAlpha: number;
transform: Matrix2D;
hasCrop: boolean;
cropRect: Rect;
globalAlpha: number;
transform: Matrix2D;
hasCrop: boolean;
cropRect: Rect;
}
function createEmptyState(): SavedState {
return {
transform: createMat2D(),
globalAlpha: 1,
hasCrop: false,
cropRect: rect(0, 0, 0, 0),
};
return {
transform: createMat2D(),
globalAlpha: 1,
hasCrop: false,
cropRect: rect(0, 0, 0, 0),
};
}
const stateCache = new ObjectCache<SavedState>(10, createEmptyState);
export abstract class BaseStateBatch {
globalAlpha = 1;
transform = createMat2D();
private savedStates: SavedState[] = [];
protected hasCrop = false;
protected cropRect = rect(0, 0, 0, 0);
crop(x: number, y: number, w: number, h: number) {
// console.error('Crop not supported');
this.hasCrop = true;
this.cropRect.x = x;
this.cropRect.y = y;
this.cropRect.w = w;
this.cropRect.h = h;
}
clearCrop() {
this.hasCrop = false;
}
save() {
const state = stateCache.get();
state.globalAlpha = this.globalAlpha;
state.hasCrop = this.hasCrop;
copyMat2D(state.transform, this.transform);
copyRect(state.cropRect, this.cropRect);
this.savedStates.push(state);
globalAlpha = 1;
transform = createMat2D();
private savedStates: SavedState[] = [];
protected hasCrop = false;
protected cropRect = rect(0, 0, 0, 0);
crop(x: number, y: number, w: number, h: number) {
// console.error('Crop not supported');
this.hasCrop = true;
this.cropRect.x = x;
this.cropRect.y = y;
this.cropRect.w = w;
this.cropRect.h = h;
}
clearCrop() {
this.hasCrop = false;
}
save() {
const state = stateCache.get();
state.globalAlpha = this.globalAlpha;
state.hasCrop = this.hasCrop;
copyMat2D(state.transform, this.transform);
copyRect(state.cropRect, this.cropRect);
this.savedStates.push(state);
if (DEVELOPMENT && this.savedStates.length > 100) {
console.error('More than 100 save states');
}
}
restore() {
const state = this.savedStates.pop();
if (DEVELOPMENT && this.savedStates.length > 100) {
console.error('More than 100 save states');
}
}
restore() {
const state = this.savedStates.pop();
if (state !== undefined) {
this.globalAlpha = state.globalAlpha;
this.hasCrop = state.hasCrop;
copyMat2D(this.transform, state.transform);
copyRect(this.cropRect, state.cropRect);
stateCache.put(state);
}
}
translate(x: number, y: number) {
translateMat2D(this.transform, this.transform, x, y);
}
scale(x: number, y: number) {
scaleMat2D(this.transform, this.transform, x, y);
}
rotate(angle: number) {
rotateMat2D(this.transform, this.transform, angle);
}
multiplyTransform(mat: Matrix2D) {
mulMat2D(this.transform, this.transform, mat);
}
if (state !== undefined) {
this.globalAlpha = state.globalAlpha;
this.hasCrop = state.hasCrop;
copyMat2D(this.transform, state.transform);
copyRect(this.cropRect, state.cropRect);
stateCache.put(state);
}
}
translate(x: number, y: number) {
translateMat2D(this.transform, this.transform, x, y);
}
scale(x: number, y: number) {
scaleMat2D(this.transform, this.transform, x, y);
}
rotate(angle: number) {
rotateMat2D(this.transform, this.transform, angle);
}
multiplyTransform(mat: Matrix2D) {
mulMat2D(this.transform, this.transform, mat);
}
}