Created
April 26, 2018 08:49
-
-
Save jack-nie/058c2fc0f6f5ab5b48d2972439d96fb0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function colorText(str,phase) | |
{ | |
if (phase == undefined) phase = 0; | |
center = 128; | |
width = 127; | |
frequency = Math.PI*2/str.length; | |
for (var i = 0; i < str.length; ++i) | |
{ | |
red = Math.sin(frequency*i+2+phase) * width + center; | |
green = Math.sin(frequency*i+0+phase) * width + center; | |
blue = Math.sin(frequency*i+4+phase) * width + center; | |
document.write( '<font style="color:' + RGB2Color(red,green,blue) + '">' + str.substr(i,1) + '</font>'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment