[ Launch: Tributary inlet ] 5310716 by danharr
-
-
Save danharr/5310716 to your computer and use it in GitHub Desktop.
Tributary inlet
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
{"endpoint":"","display":"svg","public":true,"require":[],"tab":"edit","display_percent":0.7,"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,"description":"Tributary inlet","fileconfigs":{"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false} |
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
//make a visual to be used to explain earth's orbit | |
//change trig so radius of an ellipse is calculated from any angle | |
d3.select("body").style("background-color", d3.rgb(-71,25,25)) | |
var svg = d3.select("svg"); | |
var cx = 340; | |
var cy = 418; | |
var outr = 266; | |
var outer = svg.append("ellipse") | |
.attr({ | |
cx: cx, | |
cy: cy, | |
rx: outr, | |
ry:outr, | |
fill: "none", | |
stroke: "#1B8600", | |
"stroke-width": 4 | |
}); | |
var electron = svg.append("circle") | |
.attr({ | |
cx: cx + outr, | |
cy: cy, | |
r: 15, | |
fill: "#067BA8" | |
}); | |
var drag = d3.behavior.drag() | |
.on("drag", function() { | |
var mx = d3.mouse(this)[0]; | |
var my = d3.mouse(this)[1]; | |
var omega = Math.atan2(mx - cx, my - cy); | |
var nx = outr * Math.sin(omega); | |
var ny = outr * Math.cos(omega); | |
electron.attr({ | |
cx: cx + nx, | |
cy: cy + ny | |
}) | |
}) | |
electron.call(drag); | |
svg.append('text').text('test'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment