Skip to content

Commit ee05d68

Browse files
committed
hm
1 parent 25410f5 commit ee05d68

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

font_cooker.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
<script>
104104

105105
/*
106+
[x] drag drop font file
107+
[x] copy font.h
108+
106109
[ ] emoji
107110
[ ] persist config in localStorage
108111
[ ] save config

lines_cube.html

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
window.onload = () => {
1616
const canvas = document.querySelector("#glcanvas");
17-
const gl = canvas.getContext("webgl");
17+
const gl = canvas.getContext("webgl2");
1818

1919
if (gl === null) {
2020
alert(
@@ -34,29 +34,35 @@
3434
canvas.style.height = window.innerHeight + 'px';
3535
})();
3636

37-
const vsSource = `
38-
attribute vec4 a_vpos;
39-
attribute float a_palette_index;
37+
const vsSource = `#version 300 es
38+
precision mediump float;
4039

41-
varying float v_palette_index;
40+
in vec4 a_vpos;
41+
in float a_palette_index;
42+
43+
flat out int v_palette_index;
4244

4345
void main(void) {
44-
v_palette_index = a_palette_index;
46+
v_palette_index = int(round(a_palette_index));
4547
gl_Position = a_vpos;
4648
}
4749
`;
4850

49-
const fsSource = `
50-
varying lowp float v_palette_index;
51+
const fsSource = `#version 300 es
52+
precision mediump float;
53+
54+
flat in int v_palette_index;
55+
56+
out vec4 color;
5157

5258
void main(void) {
53-
gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
54-
if (0.0 == v_palette_index) gl_FragColor = vec4(0.8, 0.1, 0.1, 1.0);
55-
if (1.0 == v_palette_index) gl_FragColor = vec4(0.1, 0.8, 0.1, 1.0);
56-
if (2.0 == v_palette_index) gl_FragColor = vec4(0.1, 0.1, 0.8, 1.0);
57-
if (3.0 == v_palette_index) gl_FragColor = vec4(1.0, 0.4, 0.4, 1.0);
58-
if (4.0 == v_palette_index) gl_FragColor = vec4(0.4, 1.0, 0.4, 1.0);
59-
if (5.0 == v_palette_index) gl_FragColor = vec4(0.4, 0.4, 1.0, 1.0);
59+
color = vec4(1.0, 0.0, 1.0, 1.0);
60+
if (0 == v_palette_index) color = vec4(0.8, 0.1, 0.1, 1.0);
61+
if (1 == v_palette_index) color = vec4(0.1, 0.8, 0.1, 1.0);
62+
if (2 == v_palette_index) color = vec4(0.1, 0.1, 0.8, 1.0);
63+
if (3 == v_palette_index) color = vec4(1.0, 0.4, 0.4, 1.0);
64+
if (4 == v_palette_index) color = vec4(0.4, 1.0, 0.4, 1.0);
65+
if (5 == v_palette_index) color = vec4(0.4, 0.4, 1.0, 1.0);
6066

6167
// gl_FragColor *= 0.6;
6268
}
@@ -203,20 +209,18 @@
203209
ibuf = new Uint16Array(8192 / 2);
204210

205211
function line(a, b, a_thick, b_thick, c, z_push=0) {
206-
const aspect_ratio = gl.canvas.clientWidth / gl.canvas.clientHeight;
207-
208212
mat4_transform_vec4(a, a, u_mvp);
209213
mat4_transform_vec4(b, b, u_mvp);
210214

211215
const dx = b[0] - a[0];
212216
const dy = b[1] - a[1];
213-
const nx = -dy; /* perp */
214-
const ny = dx*aspect_ratio;
217+
const nx = -dy;
218+
const ny = dx;
215219
const tlen = Math.sqrt(nx*nx + ny*ny);
216220
if (tlen <= 0) return;
217-
let a_tx = nx/tlen * 0.5*a_thick / aspect_ratio;
221+
let a_tx = nx/tlen * 0.5*a_thick;
218222
let a_ty = ny/tlen * 0.5*a_thick;
219-
let b_tx = nx/tlen * 0.5*b_thick / aspect_ratio;
223+
let b_tx = nx/tlen * 0.5*b_thick;
220224
let b_ty = ny/tlen * 0.5*b_thick;
221225

222226
ibuf[ibuf_i++] = 0 + vbuf_i/5;

0 commit comments

Comments
 (0)