Skip to content

Instantly share code, notes, and snippets.

@nrshrivatsan
Created August 23, 2015 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrshrivatsan/4ad9b316534c82603314 to your computer and use it in GitHub Desktop.
Save nrshrivatsan/4ad9b316534c82603314 to your computer and use it in GitHub Desktop.
Use math to draw! ;)
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="900" height="900"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.beginPath();
x1 = 100;
y1 = 140;
x2 = 460;
y2 = 50;
for (var i = 0; i < 60; i++) {
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.stroke();
x2-=10
y1+=10;
}
</script>
</body>
</html>
@nrshrivatsan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment