UNPKG

laya-coreui-es

Version:

laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改

45 lines (44 loc) 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TextAtlas = void 0; const AtlasGrid_1 = require("./AtlasGrid"); const TextTexture_1 = require("./TextTexture"); const ILaya_1 = require("../../../ILaya"); class TextAtlas { constructor() { this.texWidth = 1024; this.texHeight = 1024; this.texture = null; this.charMaps = {}; this.texHeight = this.texWidth = ILaya_1.ILaya.TextRender.atlasWidth; this.texture = TextTexture_1.TextTexture.getTextTexture(this.texWidth, this.texHeight); if (this.texWidth / TextAtlas.atlasGridW > 256) { TextAtlas.atlasGridW = Math.ceil(this.texWidth / 256); } this.atlasgrid = new AtlasGrid_1.AtlasGrid(this.texWidth / TextAtlas.atlasGridW, this.texHeight / TextAtlas.atlasGridW, this.texture.id); } setProtecteDist(d) { } getAEmpty(w, h, pt) { var find = this.atlasgrid.addRect(1, Math.ceil(w / TextAtlas.atlasGridW), Math.ceil(h / TextAtlas.atlasGridW), pt); if (find) { pt.x *= TextAtlas.atlasGridW; pt.y *= TextAtlas.atlasGridW; } return find; } get usedRate() { return this.atlasgrid._used; } destroy() { for (var k in this.charMaps) { var ri = this.charMaps[k]; ri.deleted = true; } this.texture.discard(); } printDebugInfo() { } } exports.TextAtlas = TextAtlas; TextAtlas.atlasGridW = 16;