Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created July 28, 2012 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roundrobin/3191970 to your computer and use it in GitHub Desktop.
Save roundrobin/3191970 to your computer and use it in GitHub Desktop.
just another inlet to tributary
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