p3nGu1nZz commited on
Commit
592c29d
1 Parent(s): 2c0108d
Files changed (2) hide show
  1. config.js +7 -0
  2. index.html +3 -3
config.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ // config.js
2
+
3
+ const config = {
4
+ glyphsAcrossTexture: 16
5
+ };
6
+
7
+ export { config }
index.html CHANGED
@@ -12,9 +12,9 @@
12
  <script type="module">
13
  import { mat4 } from 'https://webgpufundamentals.org/3rdparty/wgpu-matrix.module.js';
14
  import { fetchShaderCode } from './utility.js';
 
15
  const glyphWidth = 32;
16
  const glyphHeight = 40;
17
- const glyphsAcrossTexture = 16;
18
  function generateGlyphTextureAtlas() {
19
  const canvas = document.createElement('canvas');
20
  canvas.width = 512;
@@ -95,8 +95,8 @@
95
  const c = s.charCodeAt(i);
96
  if (c >= 33) {
97
  const cIndex = c - 33;
98
- const glyphX = cIndex % glyphsAcrossTexture;
99
- const glyphY = Math.floor(cIndex / glyphsAcrossTexture);
100
  const u0 = glyphX * glyphWidth / glyphCanvas.width;
101
  const v1 = glyphY * glyphHeight / glyphCanvas.height;
102
  const u1 = u0 + glyphUVWidth;
 
12
  <script type="module">
13
  import { mat4 } from 'https://webgpufundamentals.org/3rdparty/wgpu-matrix.module.js';
14
  import { fetchShaderCode } from './utility.js';
15
+ import { config } from './config.js';
16
  const glyphWidth = 32;
17
  const glyphHeight = 40;
 
18
  function generateGlyphTextureAtlas() {
19
  const canvas = document.createElement('canvas');
20
  canvas.width = 512;
 
95
  const c = s.charCodeAt(i);
96
  if (c >= 33) {
97
  const cIndex = c - 33;
98
+ const glyphX = cIndex % config.glyphsAcrossTexture;
99
+ const glyphY = Math.floor(cIndex / config.glyphsAcrossTexture);
100
  const u0 = glyphX * glyphWidth / glyphCanvas.width;
101
  const v1 = glyphY * glyphHeight / glyphCanvas.height;
102
  const u1 = u0 + glyphUVWidth;