Last active
October 21, 2017 20:06
-
-
Save bit101/abfe21f0bf08aab104ed2deb8d7c5eaa to your computer and use it in GitHub Desktop.
flow fields, iteration 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = document.getElementById("canvas"), | |
context = canvas.getContext("2d"), | |
width = canvas.width = window.innerWidth, | |
height = canvas.height = window.innerHeight; | |
var res = 10; | |
for(var x = 0; x < width; x += res) { | |
for(var y = 0; y < height; y += res) { | |
var value = (x + y) * 0.01 * Math.PI * 2; | |
context.save(); | |
context.translate(x, y); | |
context.rotate(value); | |
context.beginPath(); | |
context.moveTo(0, 0); | |
context.lineTo(res, 0); | |
context.stroke(); | |
context.restore(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment