html - How to contourn elements with a line using canvas -
i'm trying contour points using line, in theory 1 line connects , in different ways.
i'm creating 2 lines , adding half-circle in begining , @ end of lines, covers first option below, have define every pixel , in application user able define points outlined.
this code i've done i'm not sure if best way:
https://jsfiddle.net/gng0ush5/
<canvas id="mycanvas" width="646" height="350" style="border:1px solid #d3d3d3;"></canvas> <script> var c = document.getelementbyid("mycanvas"); var ctx = c.getcontext("2d"); ctx.beginpath(); ctx.moveto(150, 118); ctx.lineto(290, 170); ctx.linewidth = 10; ctx.strokestyle = 'red'; ctx.stroke(); ctx.moveto(145, 180); ctx.lineto(260, 228); ctx.stroke(); ctx.moveto(150, 120); ctx.arc(150, 150, 30, 5, math.pi / 2, true); ctx.stroke(); ctx.rotate(0.1); ctx.moveto(290, 137); ctx.arc(290, 169, 33, 5, math.pi / 1.5, false); ctx.stroke(); </script>
these patterns want cover:
Comments
Post a Comment