[ Launch: Electron Setup ] 5621566 by lewis500
-
-
Save lewis500/5621566 to your computer and use it in GitHub Desktop.
Electron Answer
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":"Electron Answer","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,"thumbnail":"http://i.imgur.com/7t9HmVM.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
var svg = d3.select("svg"); | |
var cx = tributary.sw/2; | |
var cy = tributary.sh/2; | |
var radius = 200; | |
var outer = svg.append("circle") | |
.attr({ | |
cx: cx, | |
cy: cy, | |
r: radius, | |
fill: "none", | |
stroke: "#1B8600", | |
"stroke-width": 4 | |
}); | |
var electron = svg.append("circle") | |
.attr({ | |
cx: cx + radius, | |
cy: cy, | |
r: 15, | |
fill: "#067BA8" | |
}); | |
var drag = d3.behavior.drag() | |
.on("drag", function() { | |
var mx = d3.mouse(this)[0] - cx; | |
var my = d3.mouse(this)[1] - cy; | |
var angle = Math.atan2(my, mx); | |
var nx = radius * Math.cos(angle) + cx; | |
var ny = radius * Math.sin(angle) + cy; | |
electron.attr({ | |
cx: nx, | |
cy: ny | |
}) | |
}) | |
electron.call(drag); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment