A interactive & generative site with canvas-sketch and Tone.js.
Live Demo:
const canvasSketch = require('canvas-sketch'); | |
// A handy module to compute the average signal between two frequencies | |
// https://www.npmjs.com/package/analyser-frequency-average | |
const frequencyAverage = require('analyser-frequency-average'); | |
const settings = { | |
// Animate the sketch | |
animate: true | |
}; |
include | |
(import sokol) | |
""""#define SOKOL_NO_ENTRY | |
#define SOKOL_IMPL | |
#define SOKOL_GLCORE33 | |
#include "include/sokol/sokol_app.h" | |
#include "include/sokol/sokol_gfx.h" | |
include | |
(import C) |
A interactive & generative site with canvas-sketch and Tone.js.
Live Demo:
#include <time.h> // Robert Nystrom | |
#include <stdio.h> // @munificentbob | |
#include <stdlib.h> // for Ginny | |
#define r return // 2008-2019 | |
#define l(a, b, c, d) for (i y=a;y\ | |
<b; y++) for (int x = c; x < d; x++) | |
typedef int i;const i H=40;const i W | |
=80;i m[40][80];i g(i x){r rand()%x; | |
}void cave(i s){i w=g(10)+5;i h=g(6) | |
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u |
// Adapted from @delucis | |
// https://github.com/delucis/pellicola/blob/735bd7487bdc597ac7272e4ddce9473c15f68d09/lib/frame-maker.js#L99-L134 | |
const canvasSketch = require('canvas-sketch'); | |
const settings = { | |
dimensions: [ 512, 512 ], | |
duration: 3, | |
animate: true, | |
fps: 24 |
// | |
// Author: Jonathan Blow | |
// Version: 1 | |
// Date: 31 August, 2018 | |
// | |
// This code is released under the MIT license, which you can find at | |
// | |
// https://opensource.org/licenses/MIT | |
// | |
// |
#ifdef GL_ES | |
precision mediump float; | |
precision mediump int; | |
#endif | |
varying vec4 vertColor; | |
varying vec3 vertNormal; | |
varying vec3 vertLightDir; | |
varying vec4 vertTexCoord; |
ArrayList<Rect> rects; | |
float mx, my, mm, time; | |
void setup() { | |
size(720, 720, P2D); | |
generate(); | |
} | |
void draw() { |
OpenSimplexNoise noise; | |
int numFrames = 100; | |
int margin = 50; | |
int m; | |
class Line{ | |
float lr; |
const trackTime = timing => { | |
const now = performance.now(); | |
if (!timing.startTime) timing.startTime = now; | |
const elapsed = now - timing.startTime; | |
const {duration} = timing; | |
if (duration != null && duration <= elapsed) timing.startTime = null; | |
return elapsed; | |
}; | |
const delay = (callback, duration) => { |