50.0.0: Distort, Glitch, Aliases, Other stuff

This commit is contained in:
Daniel Odendahl Jr
2017-10-28 00:42:20 +00:00
parent 0a67a97304
commit ad24f3d0e1
21 changed files with 170 additions and 76 deletions
+19
View File
@@ -102,6 +102,25 @@ class Util {
return ctx;
}
static distort(ctx, x, y, width, height, amplitude, strideLevel = 4) {
const data = ctx.getImageData(x, y, width, height);
const temp = ctx.getImageData(x, y, width, height);
const stride = width * strideLevel;
for (let i = 0; i < width; i++) {
for (let j = 0; j < height; j++) {
const xs = Math.round(amplitude * Math.sin(2 * Math.PI * 3 * (y / height)));
const ys = Math.round(amplitude * Math.cos(2 * Math.PI * 3 * (x / width)));
const dest = j * (stride + i) * strideLevel;
const src = (j + ys) * (stride + (i + xs)) * strideLevel;
data.data[dest] = temp.data[src];
data.data[dest + 1] = temp.data[src + 1];
data.data[dest + 2] = temp.data[src + 2];
}
}
ctx.putImageData(data, x, y);
return ctx;
}
static async verify(channel, user, time = 30000) {
const filter = res => {
const value = res.content.toLowerCase();