JavaScript – The canvas sin code.

By | 09/06/2019

Today’s tutorial is about using canvas with the javascript script with the use of the mathematical sin function.
This JavaScript code is simple to understand.
Start with the HTML5 source code:

Use this javascript code:

The definition of variables and function sin is easy to understand.
The first fillRect will create the area of drawing and the clearRect will draw it.
The line is drawn with the sin function called like S under time_run with a size of w.
The result can be found here:

See the Pen  canvas_sin  by Cătălin George Feștilă (@catafest) on  CodePen.

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.