How can I set Html5 Canvas FillStyle with dynamic pattern and color -
I want to dynamically set a color and pattern using the HTML5 canvas. Pattern one. PGG image is when I search the subject, then I found that you can not add fillStyle = pattern and fillStyle = color canvas size only one of them. I want to dynamically move one color in the background and image pattern. it's possible?
Any ideas will be appreciated.
>

Example code and demo:
var canvas = document.getElementById (" canvas "); Var ctx = canvas.getContext ("2D"); Var cw = canvas.width; Var ch = canvas height; Var img = new image (); Img.onload = start; Img.src = "https://dl.dropboxusercontent.com/u/139992952/multple/star.png"; Start the function () {ctx.beginPath (); Ctx.arc (150, 150, 130, 0, Math.PI * 2); Ctx.closePath (); Ctx.fillStyle = 'Lime'; Ctx.fill (); Var pattern = ctx.createPattern (IMG, 'repeat'); Ctx.fillStyle = Pattern; Ctx.fill (); } body {background color: ivory; } Canvas {range: 1px solid red; } & lt; Canvas id = "canvas" width = 300 height = 300 & gt; & Lt; / Canvas & gt;
Comments
Post a Comment