[ Launch: Tributary inlet ] 6049387 by pere
-
-
Save pere/6049387 to your computer and use it in GitHub Desktop.
Tributary inlet
This file contains hidden or 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":"Tributary inlet","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}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01} |
This file contains hidden or 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
var width = 238, | |
height = 123, | |
radius = 20; | |
var drag = d3.behavior.drag() | |
.origin(Object) | |
.on("drag", dragmove); | |
var svg = d3.select("body").selectAll("svg") | |
.data(d3.range(1).map(function() { | |
console.warn(d) | |
return {x: width / 2, y: height / 2}; })) | |
.enter().append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.append("circle") | |
.attr("r", radius) | |
.attr("cx", function(d) { return d.x; }) | |
.attr("cy", function(d) { return d.y; }) | |
.call(drag); | |
function dragmove(d) { | |
d3.select(this) | |
.attr("cx", d.x = Math.max(radius, Math.min(width - radius, d3.event.x))) | |
.attr("cy", d.y = Math.max(radius, Math.min(height - radius, d3.event.y))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment