[ Launch: dark-space ] 6631923 by ptvans
[ Launch: dark-space ] 6631582 by ptvans
[ Launch: grey-slow-wave ] 6630305 by ptvans
[ Launch: grey-slow-wave ] 6629639 by ptvans
-
-
Save ptvans/6631923 to your computer and use it in GitHub Desktop.
dark-space
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
{"description":"dark-space","endpoint":"","display":"canvas","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/b8vgU0O.png"} |
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
//GIF capture delay in milliseconds | |
tributary.delay = 80; | |
//laser math | |
//http://spot.colorado.edu/~lessley/pdf%20stuff/lasermath2.pdf | |
var x0 = 428; | |
var y0 = 340; | |
var a = 317; | |
var b = 98; | |
//var b = (n-1)/(n+10); | |
var hx = 142; | |
var hy = 525; | |
var fbase = 42.14; | |
var omega0 = 4 * Math.PI * fbase; | |
var om = omega0 * 0.19477; | |
var tempo = 2000; | |
var erasing = 0.02; | |
var linen = 0; | |
var cs = d3.interpolateHsl("#EC3F3F", "#0CE97F"); | |
var sopacity = 0.728; | |
var cf = d3.interpolateHsl("#EC3F3F", "#0CE97F"); | |
var fopacity = 0.5; | |
var radius = 3; | |
var nt = 400; | |
var to = 0.296; | |
function x(t, o) { | |
//return (a - b) * Math.cos(omega0*t) + h * Math.cos(omega0*t*(a/b-1)); | |
return (a - b) * Math.tan(o*t) + hx * Math.cos(o*t*(a-b)/b); | |
//return h * Math.cos(t*Math.PI); | |
} | |
function y(t, o) { | |
//return (a - b) * Math.sin(omega0*t) - h * Math.sin(omega0*t*(a/b-1)); | |
return (a - b) * Math.sin(o*t) - hy * Math.sin(o*t*(a-b)/b); | |
//return h * Math.sin(t*Math.PI); | |
} | |
function circle(ctx, p) { | |
//ctx.fillStyle = 'hsla(0,0%,' + 70 +'%,' + 1 + ')'; | |
ctx.beginPath(); | |
ctx.arc(p[0],p[1],radius,0,2*Math.PI); | |
ctx.fill(); | |
} | |
function line(ctx) { | |
ctx.beginPath(); | |
var i; | |
for(i=0;i<linen;i++) { | |
//ctx.strokeStyle = c(i/linen); | |
ctx.lineTo(x0 + x(i/linen, omega0), y0 + y(i/linen, omega0)); | |
} | |
ctx.stroke(); | |
} | |
tributary.init = function(ctx) { | |
ctx.globalCompositeOperation = 'source-over'; | |
}; | |
tributary.run = function(ctx,t) { | |
//tributary.clear(); //helper function to clear the canvas | |
ctx.fillStyle = "rgba(0,0,0," + erasing + ")"; | |
ctx.fillRect(0,0,tributary.sw,tributary.sh); | |
var tt = (t % 10)/tempo; | |
var p; | |
ctx.strokeStyle = cs(tt); | |
line(ctx); | |
p = [x0 + x(tt, om), y0 + y(tt, om)]; | |
ctx.fillStyle = cf(tt); | |
circle(ctx, p); | |
var i = 0; | |
for(i = 0; i < nt; i++) { | |
//p = [x0 + x(tt+i*tt/2, om), y0 + y(tt+i*tt/2, om)]; | |
p = [x0 + x(tt+i*to, om), y0 + y(tt+i*to, om)]; | |
ctx.fillStyle = "#74858D"; | |
circle(ctx, p); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment