html5 - Text drawn in HTML canvas has edges -
i draw text "hello world" inside text couple of times inside 'canvas' in html5. outmost text red, next yellow, inside green text, , inner text blue.
what can sharp edges see on letter w?
how can make text render smoothly?
<canvas id="can" width="1200" height="500" dir="ltr"> <script> var can = document.getelementbyid("can"); var context = can.getcontext("2d"); context.font = "200px arial"; context.linewidth = 40; context.strokestyle = "red"; context.stroketext("hello world", 25, 200); context.linewidth = 30; context.strokestyle = "yellow"; context.stroketext("hello world", 25, 200); context.linewidth = 10; context.strokestyle = "lightgreen"; context.stroketext("hello world", 25, 200); context.fillstyle = "blue"; context.filltext("hello world", 25, 200); </script> </canvas>
i not expert sorry cannot explain why , can tell linewidth doing w
i did made smoother
<canvas id="can" width="1200" height="500" dir="ltr"> <script> var can = document.getelementbyid("can"); // used clearing canvas can.width = can.width; var context = can.getcontext("2d"); context.font = "220px arial"; context.linewidth = 11; context.strokestyle = "red"; context.stroketext("hello world", 25, 202); context.linewidth = 10; context.strokestyle = "yellow"; context.stroketext("hello world", 25, 202); context.linewidth = 4; context.strokestyle = "lightgreen"; context.stroketext("hello world", 25, 200); context.fillstyle = "blue"; context.filltext("hello world", 25, 200); </script> </canvas>
live demo http://jsfiddle.net/maree_chaudhry/wmsfb/1/
i know nt same still smooth if find better way solve please share me :)
Comments
Post a Comment