Last active
September 6, 2023 07:44
-
-
Save Langerz82/d3284e1ba2192699e438a9ae87974bf6 to your computer and use it in GitHub Desktop.
Apply Text Stroke Made into a function by className.
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
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