🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Wplace Overlay Pro

Overlays tiles on wplace.live. Can also resize, and color-match your overlay to wplace's palette. Make sure to comply with the site's Terms of Service, and rules! This script is not affiliated with Wplace.live in any way, use at your own risk. This script is not affiliated with TamperMonkey. The author of this userscript is not responsible for any damages, issues, loss of data, or punishment that may occur as a result of using this script. This script is provided "as is" under GPLv3.

< Feedback on Wplace Overlay Pro

سوئال / ئىنكاس

§
يوللانغان ۋاقتى: 2025-12-04

Symbol loading speed improvement

Symbols valid indexes can be easily cached instead of being checked at each step as such:

  var SYMBOL_CACHE = Array.from(SYMBOL_TILES).map((symbol) => {
      const scale = MINIFY_SCALE_SYMBOL;
      const tileW = TILE_SIZE * scale;
      const centerX = scale - SYMBOL_W >> 1;
      const centerY = scale - SYMBOL_H >> 1;
      const cache = []
      for (let sy = 0; sy < SYMBOL_H; sy++) {
          for (let sx = 0; sx < SYMBOL_W; sx++) {
              const bit_idx = sy * SYMBOL_W + sx;
              const bit = symbol >>> bit_idx & 1;

              if (!bit) continue;

              const precomputeX = (sx + centerX) * 4;
              const precomputeY = (sy + centerY) * 4 * tileW;

              cache.push(precomputeX + precomputeY);
          }
      }
      return cache;
  });

And then in buildOverlayDataForChunkUnified instead of the double for loop we can have


SYMBOL_CACHE[colorIndex].forEach((precomputed_idx) => {
    const outIdx = precomputed_idx + 4 * tileX + 4 * tileY * tileW;
    outData[outIdx] = a_r;
    outData[outIdx + 1] = a_g;
    outData[outIdx + 2] = a_b;
    outData[outIdx + 3] = 255;
});

Indeed this implementation ignores if (outX >= 0 && outX < tileW && outY >= 0 && outY < tileH) check but from my limited testing that is never hit

And probably should not be hit as long as the symbols are defined correctly, but most likely the check can also be added with this caching method

جاۋاب قايتۇرۇش

جاۋاب قايتۇرۇش ئۈچۈن كىرىش.