diff --git a/clickme.html b/clickme.html new file mode 100644 index 0000000..9b47846 --- /dev/null +++ b/clickme.html @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/codes/code_gonlyk.js b/codes/code_gonlyk.js new file mode 100644 index 0000000..91a572e --- /dev/null +++ b/codes/code_gonlyk.js @@ -0,0 +1,24 @@ +var code = {} + +code.red = function (x, y) { + const [dx, dy] = [2 * x / 1024 - 1, 2 * y / 1024 - 1] + const r = Math.abs(Math.atan2(dy, dx)) + return Math.sin(r) * 255 +} + +code.blue = function (x, y) { + const [dx, dy] = [2 * x / 1024 - 1, 2 * y / 1024 - 1] + const l = Math.sqrt(dx * dx + dy * dy) + return Math.cos((Math.ceil(l) - l) * 3) * 255 +} + +code.green = function (x, y) { + const [dx, dy] = [2 * x / 1024 - 1, 2 * y / 1024 - 1] + return Math.cos(dx + 1 - dy) * 255 +} + +code.author = { + id: 'gonlyk', + githubId: 'your github gonlyk', + description: '燕宝 燕宝 撒鼻息' +} diff --git a/main.js b/main.js index 41d9eee..a5838f0 100644 --- a/main.js +++ b/main.js @@ -1,20 +1,59 @@ var code = {} +const tsubame = function (x, y) { + const [tx1, ty1] = [x / 1024 - 0.8, y / 1024 - 0.2] + const [tx2, ty2] = [x / 1024 - 0.95, y / 1024 - 0.2] + const r1 = Math.atan2(ty1, tx1) + const l1 = Math.sqrt(tx1 * tx1 + ty1 * ty1) + const r2 = Math.atan2(ty2, tx2) + const l2 = Math.sqrt(tx2 * tx2 + ty2 * ty2) + if ((l1 > 0.07 && l1 < 0.08 && r1 > -Math.PI / 2 && r1 < 0) || + (l2 > 0.07 && l2 < 0.08 && r2 > -Math.PI && r2 < -Math.PI / 2)) + return 1 + + return 0 +} code.red = function (x, y) { + const [dx, dy] = [2 * x / 1024 - 1, 2 * y / 1024 - 1] + const r = -(Math.atan2(dy, dx)) + const l = Math.sqrt(dx * dx + dy * dy) + const background = Math.sin(r) + const sun = (l > 0.3 ? 0 : 1) + + const tbm = tsubame(x, y) + if (l < 0.3) { + return (0.2 * background + 0.8 * sun) * 255 + } else { + return (tbm === 1 ? 1 - background : background) * 255 + } } code.blue = function (x, y) { - + const [dx, dy] = [2 * x / 1024 - 1, 2 * y / 1024 - 1] + const l = Math.sqrt(dx * dx + dy * dy) + const background = Math.cos((Math.ceil(l) - l) * 3) + const sun = (l > 0.3 ? 0 : 0.3) + const tbm = tsubame(x, y) + if (l < 0.3) { + return (0.2 * background + 0.8 * sun) * 255 + } else { + return (tbm === 1 ? 1 - background : background) * 255 + } } code.green = function (x, y) { - + const [dx, dy] = [2 * x / 1024 - 1, 2 * y / 1024 - 1] + const background = Math.cos(dx + 1 - dy) + const tbm = tsubame(x, y) + return (tbm === 1 ? 1 - background : background) * 255 } let canvas = document.getElementById('canvas') let ctx = canvas.getContext('2d') let size = 1024 +window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; + for (let x = 0; x < size; x++) { for (let y = 0; y < size; y++) { ctx.fillStyle = 'rgb(' + code.red(x, y) + ',' + code.green(x, y) + ',' + code.blue(x, y) + ')' diff --git a/shader.frag b/shader.frag new file mode 100644 index 0000000..82b939a --- /dev/null +++ b/shader.frag @@ -0,0 +1,22 @@ +#ifdef GL_ES +precision mediump float; +#endif + +uniform vec2 u_resolution; +uniform float u_time; + +vec3 colorA = vec3(0.149,0.141,0.912); +vec3 colorB = vec3(1.000,0.833,0.224); + +void main() { + vec3 color = vec3(0.0); + + float pct = abs(sin(u_time)); + + + // Mix uses pct (a value from 0-1) to + // mix the two colors + color = mix(colorA, colorB, pct); + + gl_FragColor = vec4(color,1.0); +} \ No newline at end of file