Created
July 28, 2012 05:46
-
-
Save roundrobin/3191970 to your computer and use it in GitHub Desktop.
just another inlet to tributary
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
path = g.append("path") | |
.attr("stroke","black") | |
.attr("stroke-width",3) | |
.attr("fill","none") | |
.attr("d","M0,0 L100,100 L200,200") | |
boxHeight = 374 | |
g.append("rect") | |
.attr("width",boxHeight) | |
.attr("height",boxHeight) | |
.attr("x",0) | |
.attr("y",0) | |
.style("opacity",0.5) | |
currentScale = 1 | |
bb = path.node().getBBox() | |
width = bb.width | |
height = bb.height | |
boxHeight = boxHeight | |
boxWidth = boxHeight | |
textWidth = bb.width | |
textHeight = bb.height | |
currentSF = 1 | |
maxWidth = (boxWidth / textWidth ) | |
maxHeight = (boxHeight /textHeight) | |
max = Math.min(maxWidth, maxHeight) | |
scaling = (currentSF * max) | |
console.log '-------------', boxHeight, height,maxHeight,scaling | |
path.attr('transform','scale('+scaling+')') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment