Skip to content

Commit

Permalink
fix split rgb
Browse files Browse the repository at this point in the history
  • Loading branch information
eyaler committed Oct 15, 2024
1 parent d7c2782 commit ec2fb24
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,16 @@ const effect_funcs = {
},

rgb_split: (W, H, rgbx) => {
const shift = devicePixelRatio * 5 | 0
let shift_gx = devicePixelRatio * 4 | 0
let shift_gy = devicePixelRatio * 2 | 0
let shift_rx = 2 * shift_gx
let shift_ry = 2 * shift_gy
for (let y = 0; y < H; y++)
for (let x = 0; x < W; x++) {
const index4 = (x+y*W) * 4
if (x < W - shift*2) {
rgbx[index4] = rgbx[(shift*2+x+y*W) * 4]
if (x < W - shift)
rgbx[index4 + 1] = rgbx[(shift+x+y*W) * 4 + 1]
}
}
rgbx[index4] = rgbx[(Math.min(x + shift_rx, W - 1)+Math.min(y + shift_ry, H - 1)*W) * 4]
rgbx[index4 + 1] = rgbx[(Math.min(x + shift_gx, W - 1)+Math.min(y + shift_gy, H - 1)*W)*4 + 1]
}
},
}

Expand Down

0 comments on commit ec2fb24

Please sign in to comment.