1 Star 0 Fork 1

autumndawn/maxrects

forked from eric/maxrects 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
abstract-bin.ts 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
eric 提交于 2024-03-20 11:28 . *初版
import { IRectangle, Rectangle } from "./geom/Rectangle";
import { IOption } from "./maxrects-packer";
export interface IBin {
width: number
height: number
maxWidth: number
maxHeight: number
freeRects: IRectangle[]
rects: IRectangle[]
options: IOption
[propName: string]: any
}
export abstract class Bin<T extends IRectangle> implements IBin {
public width!: number;
public height!: number;
public maxWidth!: number;
public maxHeight!: number;
public freeRects!: IRectangle[];
public rects!: T[];
public options!: IOption;
public abstract add (rect: T): T | undefined;
public abstract add (width: number, height: number, data: any): T | undefined;
public abstract reset (deepRest: boolean): void;
public abstract repack (): T[] | undefined;
public data?: any;
public tag?: string;
protected _dirty: number = 0;
get dirty (): boolean { return this._dirty > 0 || this.rects.some(rect => rect.dirty); }
/**
* Set bin dirty status
*
* @memberof Bin
*/
public setDirty (value: boolean = true): void {
this._dirty = value ? this._dirty + 1 : 0;
if (!value) {
for (let rect of this.rects) {
if (rect.setDirty) rect.setDirty(false);
}
}
}
public abstract clone (): Bin<T>;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/autumndawn/maxrects.git
git@gitee.com:autumndawn/maxrects.git
autumndawn
maxrects
maxrects
master

搜索帮助