LCOV - code coverage report
Current view: top level - maps/random/rmgen/painter - TerrainTextureArrayPainter.js (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 8 12.5 %
Date: 2023-04-02 12:52:40 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /**
       2             :  * Paints the given texture-mapping to the given tiles.
       3             :  *
       4             :  * @param {string[]} textureIDs - Names of the terrain textures
       5             :  * @param {number[]} textureNames - One-dimensional array of indices of texturenames, one for each tile of the entire map.
       6             :  * @returns
       7             :  */
       8             : function TerrainTextureArrayPainter(textureIDs, textureNames)
       9             : {
      10           0 :         this.textureIDs = textureIDs;
      11           0 :         this.textureNames = textureNames;
      12             : }
      13             : 
      14           6 : TerrainTextureArrayPainter.prototype.paint = function(area)
      15             : {
      16           0 :         let sourceSize = Math.sqrt(this.textureIDs.length);
      17           0 :         let scale = sourceSize / g_Map.getSize();
      18             : 
      19           0 :         for (let point of area.getPoints())
      20             :         {
      21           0 :                 let sourcePos = Vector2D.mult(point, scale).floor();
      22           0 :                 g_Map.setTexture(point, this.textureNames[this.textureIDs[sourcePos.x * sourceSize + sourcePos.y]]);
      23             :         }
      24             : };

Generated by: LCOV version 1.14