[ Launch: test ] 701aebdf05d2cf886e4d by georules
[ Launch: test ] 4653053 by enjalot
[ Launch: test ] 4652017 by enjalot
[ Launch: test ] 4582399 by enjalot
-
-
Save georules/701aebdf05d2cf886e4d to your computer and use it in GitHub Desktop.
hexes
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":"hexes","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}},"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,"tab":"edit","display_percent":0.7,"thumbnail":"http://i.imgur.com/cPwGVcR.png","fullscreen":false,"ajax-caching":true,"inline-console":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
var svg = d3.select("svg") | |
svg.append("rect") | |
.attr({ | |
width: 100, | |
height: 100, | |
x: 200, | |
y: 62, | |
fill: "#3BA360" | |
}); | |
var Hex = function() {} | |
Hex.convpoints = function(d) { | |
return d.map(function(d) { | |
return [d.x,d.y].join(","); | |
}).join(" ") | |
} | |
Hex.svgData = function(x,y,r) { | |
return Hex.convpoints(Hex.hexPoints(x,y,r)) | |
} | |
Hex.hexPoints = function(x,y,r) { | |
h = Math.sqrt(3)/2 | |
hexagonData = [ | |
{x : r+x, y: y}, | |
{x : r/2+x, y: r*h+y}, | |
{x : -r/2+x, y: r*h+y}, | |
{x : -r+x, y: y}, | |
{x : -r/2+x, y: -r*h+y}, | |
{x : r/2+x, y: -r*h+y} | |
] | |
return hexagonData | |
} | |
//points = hex(100,100,76) | |
//newp = convpoints(points) | |
newp = Hex.svgData(135,204,108) | |
//newp = ["100,100","70,367","300,300"] | |
svg.append("polygon").attr({ | |
"points":newp, | |
"stroke-width":2, | |
fill: "#ff7f7f", | |
stroke: "#ef0000" | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment