admin管理员组文章数量:1430967
textarea
{text-shadow:white 0px 1px 0px, white 0px -1px 0px, white -1px 0px 0px, white 1px 0px 0px, white -1px 1px 0px, white 1px 1px 0px, white -1px -1px 0px, white 1px -1px 0px, white 0px 1.5px 0px, white 0px -1.5px 0px, white -1.5px 0px 0px, white 1.5px 0px 0px, white -1.5px 1.5px 0px, white 1.5px 1.5px 0px, white -1.5px -1.5px 0px, white 1.5px -1.5px 0px, rgb(133, 133, 133) 0px -1px 4px, rgb(133, 133, 133) 0px 3px 4px, rgb(133, 133, 133) 3px 0px 4px, rgb(133, 133, 133) -3px 0px 4px;
color:red;
}
<textarea >default text in the textarea
</textarea>
textarea
{text-shadow:white 0px 1px 0px, white 0px -1px 0px, white -1px 0px 0px, white 1px 0px 0px, white -1px 1px 0px, white 1px 1px 0px, white -1px -1px 0px, white 1px -1px 0px, white 0px 1.5px 0px, white 0px -1.5px 0px, white -1.5px 0px 0px, white 1.5px 0px 0px, white -1.5px 1.5px 0px, white 1.5px 1.5px 0px, white -1.5px -1.5px 0px, white 1.5px -1.5px 0px, rgb(133, 133, 133) 0px -1px 4px, rgb(133, 133, 133) 0px 3px 4px, rgb(133, 133, 133) 3px 0px 4px, rgb(133, 133, 133) -3px 0px 4px;
color:red;
}
<textarea >default text in the textarea
</textarea>
How to apply this text shadow in the canvas text. I searched for various ways like this (http://jsfiddle/DirkWeber/nnqc8/1/light/) and I'm not able to replicate this type of text shadow in canvas text. Please let me know how to achieve this.
Share Improve this question edited Jun 4, 2018 at 5:34 Cœur 38.8k25 gold badges206 silver badges279 bronze badges asked Feb 20, 2017 at 2:41 AshokkumarAshokkumar 3254 silver badges18 bronze badges 1- Use a mixture of shadowing, fill color, stroke color and stroke width to approximate your effect ... Adjust as needed for font size – markE Commented Feb 20, 2017 at 4:19
1 Answer
Reset to default 8Canvas example
var canvas = document.getElementsByTagName("canvas")[0],
ctx = canvas.getContext('2d');
ctx.font="75px verdana";
ctx.shadowColor="black";
ctx.shadowBlur=10;
ctx.lineWidth=10;
ctx.strokeStyle = "white";
ctx.strokeText("HELLO",25,100);
ctx.shadowBlur=0;
ctx.fillStyle="red";
ctx.fillText("HELLO",25,100);
<canvas id="c" width="300" height="130"></canvas>
CSS example
.text {font-size: 3em;
-webkit-text-stroke: 2px white;
-webkit-text-fill-color: black;
-webkit-animation: fill 1s infinite alternate;
text-shadow:2px 2px 10px #000;
}
<div class="text">default text in the textarea
</div>
本文标签: javascriptHow to achieve this text shadow in canvas textStack Overflow
版权声明:本文标题:javascript - How to achieve this text shadow in canvas text - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745514653a2661470.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论