Skip to content

Instantly share code, notes, and snippets.

@bit101
bit101 / flow_fields_03.js
Created October 21, 2017 18:58
flow fields, iteration 3
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
var count = 20000;
for(var i = 0; i < count; i++) {
var x = Math.random() * width,
y = Math.random() * height;
@bit101
bit101 / flow_fields_02.js
Created October 21, 2017 18:46
flow fields, iteration 2
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 = getValue(x, y);
@bit101
bit101 / tutorial_main.js
Created October 21, 2017 18:43
JavaScript Template for tutorials
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
@bit101
bit101 / tutorial_index.html
Created October 21, 2017 18:43
HTML Template for tutorials
<!doctype html>
<html>
<head>
<title>tuturial template</title>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
canvas {
@bit101
bit101 / flow_fields_01.js
Last active October 21, 2017 20:06
flow fields, iteration 1
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;