[ Launch: Tributary inlet ] 8294728 by dvdrtrgn
-
-
Save dvdrtrgn/8294728 to your computer and use it in GitHub Desktop.
trontime
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
section#display { | |
border: 1px solid yellow; | |
} | |
svg { | |
border: 1px solid purple; | |
} | |
.red { | |
stroke: red; | |
stroke-width: 0.7; | |
} | |
.blue { | |
stroke: blue; | |
stroke-width: 0.3; | |
} | |
.green { | |
stroke: green; | |
stroke-width: 0.5; | |
} | |
.white { | |
stroke: white; | |
stroke-width: 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
{"description":"trontime","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"test":{"default":true,"vim":false,"emacs":false,"fontSize":12},"base.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"foo.scss":{"default":true,"vim":false,"emacs":false,"fontSize":12},"xtra.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"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/Aa4yDch.gif","inline-console":true} |
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
/*jslint es5:true, white:false */ | |
/*globals d3 */ | |
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | |
var gap = 50, | |
height = 500, | |
width = 500, | |
chart = 200, | |
svg; | |
// some constants and inits | |
var a = 106, | |
edge = a * 2, | |
current_angle = 0, | |
start_coords = {x: 0, y: 0}, | |
coordinate_map = [], | |
draw_ident_arrow = false; | |
svg = d3.select('svg') // | |
.attr({ | |
'width': width, | |
'height': height, | |
}); | |
svg.attr("transform", "translate(" + [259, 338] + ")") | |
function nugroup(x, y) { | |
x = x || 10; | |
y = y || 10; | |
group = svg.append('svg:g') // | |
.attr('transform', 'scale(1.792) translate(' + x + ', ' + (y + chart) + ')'); | |
} | |
function line(x1, y1, x2, y2, cls) { | |
group.append('svg:line').attr({ | |
x1: (x1 || 1), | |
y1: (y1 || 1) * -1, | |
x2: (x2 || 1), | |
y2: (y2 || 1) * -1, | |
}).attr('class', cls || 'red'); | |
} | |
function makeGrid(inc, wi, hi) { | |
var i; | |
hi = (hi || wi); // go square? | |
nugroup(10, 10); | |
for (i = 0; i <= hi; i += inc) { // horizontal lines | |
line(0, i, wi, i, 'blue'); | |
} | |
for (i = 0; i <= wi; i += inc) { // vertical lines | |
line(i, 0, i, hi, 'green'); | |
} | |
} | |
makeGrid(10, chart, chart); | |
function makeData(tot, fac) { | |
tot = tot || 10; | |
fac = fac || 20; | |
var arr = [], | |
i, m, tmp; | |
for (i = 0; i <= tot; i++) { | |
m = i * fac; | |
tmp = [0, tot * fac - m, m, 0]; | |
line.apply(null, tmp); | |
arr.push(tmp); | |
makePlot(tmp[0], tmp[1]); | |
makePlot(tmp[2], tmp[3]); | |
} | |
return arr; | |
} | |
console.debug(makeData(36, 6)); | |
function makePlot(x, y) { | |
var z = 2; | |
if (!y && typeof x === 'object') { | |
x.each(function (a) { | |
makePlot(a[0], a[1]); | |
}); | |
} else { | |
line.apply(this, [x - z, y - z, x + z, y + z, 'white']); | |
line.apply(this, [x + z, y - z, x - z, y + z, 'white']); | |
} | |
} | |
makePlot(chart / 2, chart / 2); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment