Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created July 3, 2012 23:23
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/3044119 to your computer and use it in GitHub Desktop.
Save roundrobin/3044119 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var width = 557
var height = 190
var font_size = 557
var x = 58
var y = 119
var rect = g.append("rect")
.attr("width",width)
.attr("height",height)
.attr("fill","black")
.attr("x",x)
.attr("y",y)
var text1 = g.append("text")
.attr("fill","red")
.attr("x",x)
.attr("y",y)
.attr("font-size",font_size)
.text("Heyg|gggggggggggrrrrrrrrwerwegggfdfgf")
.style('dominant-baseline','text-before-edge')
.style('font-family','')
var boundingBoxOfTextNode = text1.node().getBBox();
var textLength = text1.node().getComputedTextLength();
var a1 = width;
var b1 = font_size;
var c1 = textLength;
text1.attr("font-size",(a1 * (b1/c1)))
var a = height;
var b = font_size;
var c = boundingBoxOfTextNode.height;
text1.attr("font-size",(a * (b/c)))
console.log((a * (b/c)),a1 * (b1/c1),'Aspect Box',width/height,"Apect Text",textLength/boundingBoxOfTextNode.height)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment