Skip to content

Instantly share code, notes, and snippets.

@bit101
bit101 / trig_01_01.js
Last active November 5, 2017 18:00
trig 1, iteration 1
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
var waveCount = 1,
waveHeight = height / 2 - 10,
res = 1;
context.translate(0, height / 2);
@bit101
bit101 / flow_fields_2_05.js
Created October 28, 2017 16:39
flow fields 2, iteration 5
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d");
var points;
var bitmap = Bitmap.create("cat.jpg", onComplete);
var force = 0.007;
var friction = 0.99;
function onComplete() {
canvas.width = bitmap.width;
@bit101
bit101 / flow_fields_2_04.js
Created October 27, 2017 02:33
flow fields 2, iteration 4
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
context.lineWidth = 0.1;
var z = 0;
noise.seed(Math.random());
render();
@bit101
bit101 / flow_fields_2_03.js
Created October 27, 2017 02:26
flow fields 2, iteration 3
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
context.lineWidth = 0.1;
// create points. each aligned to left edge of screen,
// spread out top to bottom.
var points = [];
@bit101
bit101 / flow_fields_2_index.html
Created October 27, 2017 02:03
flow fields 2 index
<!doctype html>
<html>
<head>
<title>Flow Fields</title>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
canvas {
@bit101
bit101 / flow_fields_2_02.js
Created October 27, 2017 01:57
flow fields 2, iteration 2
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
noise.seed(Math.random());
var z = 0;
render();
function render() {
@bit101
bit101 / flow_fields_2_01.js
Last active October 27, 2017 01:48
flow fields 2, iteration 1
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
noise.seed(Math.random());
render();
function render() {
var res = 10;
@bit101
bit101 / flow_fields_06.js
Last active October 22, 2017 22:18
flow fields, iteration 6
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
context.lineWidth = 0.1;
// random attractor params
var a = Math.random() * 4 - 2;
var b = Math.random() * 4 - 2;
@bit101
bit101 / flow_fields_05.js
Created October 22, 2017 16:36
flow fields, iteration 5
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
context.lineWidth = 0.5;
// create point
var p = {
x: Math.random() * width,
@bit101
bit101 / flow_fields_04.js
Created October 22, 2017 16:10
flow fields, iteration 4
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
var count = 50000;
context.lineWidth = 0.25;
for(var i = 0; i < count; i++) {
var x = Math.random() * width,