DEV Community

Cover image for Making 'The Matrix' Effect in Javascript

Making 'The Matrix' Effect in Javascript

Ganesh Prasad on September 20, 2019

I have always been a big fan of the movie series 'The Matrix Trilogy'. In this article we will make the following visual effect from the matrix ser...
Collapse
 
stealthmusic profile image
Jan Wedel • Edited

Nice work. I don’t recall the exact matrix effects, but I think you should remove the space character from the possible result set... It looks like some columns start somewhere in the middle. Maybe some modulo/offset calculation would do the trick.

Collapse
 
deepu105 profile image
Deepu K Sasidharan

Nice. I remember doing this in Flash/Actionscript around 10 years ago

Collapse
 
jaimecortes5681 profile image
Jaime Cortes

Great work, I improve a little:

  1. you can asign a font in http; so i doit a Matrix font like: fontmeme.com/fonts/matrix-code-nfi...

  2. I read a text in files instead a random characters, i thing is better distribution of character sets

Look my improves:
jaimecortesproject.000webhostapp.c...

feel free to use.

Collapse
 
jcortesm5681 profile image
jcortesm5681

Me again, look the improves here:

github.com/jcortesm5681/MatrixHTML

feel free to use.

Collapse
 
jcubic profile image
Jakub T. Jankiewicz

I've created a library with the Matrix effect. It's based on CodePen demo, I think it looks much better. The original code was much simpler and also looks better because it use Japanese characters.

GitHub logo jcubic / cmatrix

Render Matrix effect animation on Canvas in JavaScript

CMatrix - Matrix effect in JavaScript

npm LICENSE MIT

Matrix animation effect in JavaScript using Canvas

Screenshot of a browser window with Matrix rain effect, green letters that look like Japanese on black background

Installation

npm install cmatrix

Demos

Usage

You can use CDN:

<script src="https://cdn.jsdelivr.net/npm/cmatrix"></script>
Enter fullscreen mode Exit fullscreen mode

and intialize the effect.

matrix(canvasElement, {
  chars: ['0', '1'],
  font_size: 16
}).
Enter fullscreen mode Exit fullscreen mode
matrix(canvasElement, {
  chars: matrix.range(0x30A1, 0x30F6).concat(matrix.range(0x0030, 0x0039)),
  font_size: 16
}).
Enter fullscreen mode Exit fullscreen mode

The matrix function return a Promise that is resolved when exit By default, q and ESC exit from the effect. Use exit: false to disable ending the animation.

Repo Link

Options

  • chars - array of single character strings, by default Katagana and Hiragana (Japanese characters are used).
  • exit - by default matrix return…
Collapse
 
5anthosh profile image
Santhosh Kumar

That is so coool !

Collapse
 
mikeowsky profile image
Mikeowsky-2104

could you please tell how I can write some text first and then run animation plz

Collapse
 
paulasantamaria profile image
Paula Santamaría

It looks so smooth! Great job 👏👏👏

Collapse
 
jude_johnbosco profile image
Chinweike Jude Obiejesi

So cool, nice one

Collapse
 
pranav1326 profile image
Pranav

The power of vanilla js🤘

Collapse
 
alekosescu profile image
Alejandro Escudero

Really COOL!!

Collapse
 
bbborisk profile image
bbborisk

Very cool

Collapse
 
yopensourc profile image
Yogesh Mali

nise one !

Collapse
 
dansilcox profile image
Dan Silcox

Nice!

Collapse
 
lucasfrutig0 profile image
lucasfrutig0

ohh cool!!

Collapse
 
giannifed profile image
Gianni Feduzi

Nice

Collapse
 
cloud7solutions profile image
Cloud7Solutions

Fantastic work!
I slightly updated the code to show some vertically scrolling messages, just for the sake of it.