Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created February 25, 2014 07:36
Show Gist options
  • Save roundrobin/9204525 to your computer and use it in GitHub Desktop.
Save roundrobin/9204525 to your computer and use it in GitHub Desktop.
Center by char
{"description":"Center by char","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}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/VdV06QW.png"}
var xOffset = 400;
var text = g.append("text")
.attr({
y: 200,
x: 0,
"font-size": 60
})
text.append("tspan")
.text("Hel");
text.append("tspan")
.style({fill:"red"})
.text("l");
text.append("tspan")
.text("o");
var pos = text.node().getStartPositionOfChar(4);
text.attr({
x: xOffset - pos.x
});
var text2 = g.append("text")
.attr({
y: pos.y,
x: 0,
"font-size": 60
})
text2.append("tspan")
.text("Check");
text2.append("tspan")
.style({fill:"red"})
.text(" t");
text2.append("tspan")
.text("hat out");
var pos2 = text2.node().getStartPositionOfChar(7);
text2.attr({
x: xOffset-pos2.x,
y: 250
});
var text3 = g.append("text")
.attr({
y: pos.y,
x: 0,
"font-size": 60
})
text3.append("tspan")
.text("Lorem ipsum");
text3.append("tspan")
.style({fill:"red"})
.text(" d");
text3.append("tspan")
.text("olor sitt");
var pos3 = text3.node().getStartPositionOfChar(13);
text3.attr({
x: xOffset - pos3.x,
y: 300
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment