diff --git a/src/script.js b/src/script.js index 0c54809..d83d9fb 100644 --- a/src/script.js +++ b/src/script.js @@ -160,6 +160,9 @@ async function draw() { let colorLocation = gl.getUniformLocation(program, "color"); gl.uniform3f(colorLocation, ...hslToRgb(hue, 1, 0.5)); + let positionLocation = gl.getUniformLocation(program, "position"); + gl.uniform2f(positionLocation, Math.cos(hue * 2 * Math.PI) * 0.2, Math.sin(hue * 2 * Math.PI) * 0.2); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); gl.drawArrays(gl.TRIANGLES, 0, vertices.length / 2); diff --git a/src/shaders/vertex.glsl b/src/shaders/vertex.glsl index bdfa378..a73487f 100644 --- a/src/shaders/vertex.glsl +++ b/src/shaders/vertex.glsl @@ -2,9 +2,10 @@ precision mediump float; attribute vec2 vertPosition; uniform vec3 color; +uniform vec2 position; varying vec3 fragColor; void main() { fragColor = color; - gl_Position = vec4(vertPosition, 0.0, 1.0); + gl_Position = vec4(position + vertPosition, 0.0, 1.0); } \ No newline at end of file