Skip to content

Instantly share code, notes, and snippets.

@Langerz82
Last active September 6, 2023 07:44
Show Gist options
  • Save Langerz82/d3284e1ba2192699e438a9ae87974bf6 to your computer and use it in GitHub Desktop.
Save Langerz82/d3284e1ba2192699e438a9ae87974bf6 to your computer and use it in GitHub Desktop.
Apply Text Stroke Made into a function by className.
var applyTextStroke = function (className, color, width)
{
var r = width;
var n = Math.ceil(2*Math.PI*r); /* number of shadows */
var str = '';
for(var i = 0;i<n;i++) /* append shadows in n evenly distributed directions */
{
var theta = 2*Math.PI*i/n;
str += (r*Math.cos(theta))+"px "+(r*Math.sin(theta))+"px 0 "+color+(i==n-1?"":",");
}
var arr = document.getElementsByClassName(className);
for (var dom of arr)
{
dom.style.textShadow = str;
}
};
applyTextStroke("frame-stroke", "#333", 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment