Skip to content

Instantly share code, notes, and snippets.

View c-t-n's full-sized avatar
< My kind of bootstrap material

Franck LOURME c-t-n

< My kind of bootstrap material
View GitHub Profile
@lqt0223
lqt0223 / g.md
Last active June 25, 2024 15:04
14 Simple algorithm for chromatic aberration effect in JavaScript

Chromatic aberration effect - a simple implementation in JavaScript

A chromatic aberration is an optical effect caused by one or more color channels being displaced. Although it is an optical failure and should be avoided for displaying or image capturing devices, chromatic aberration can be used to make graphics be more realistic in some other applications like 3D games.

The following codes is an example of implementing the effect using ImageData API of HTML5 canvas. By fetching and manipulating pixel data of the image, the chromatic aberration effect is easy to achieve.

<html>
<body>
<canvas id="canvas"></canvas>