Answer the question
In order to leave comments, you need to log in
Canvas Ctx.fillStyle how to make dynamic color?
Hello! The essence is this, the text is taken from the form and converted into a picture by this script:
var tCtx = document.getElementById('textCanvas').getContext('2d'),
imageElem = document.getElementById('image');
document.getElementById('sign').addEventListener('keyup', function (){
tCtx.canvas.width = tCtx.measureText(this.value).width;
tCtx.font = "50px serif";
tCtx.fillStyle = "#FFFFFF";
tCtx.fillText (this.value, 0, 80);
imageElem.src = tCtx.canvas.toDataURL();
console.log(imageElem.src);
}, false);
<img id="black" class="activeColor" data-color="black" data-colorreal="Черный" src="images/icon_black.png" style="border-radius: 50px; box-shadow: rgba(122, 122, 122, 0.901961) 0.1em 0.1em 9px;" hspace="10" vspace="10">
<img id="white" data-color="white" data-colorreal="Белый" src="images/icon_white.png" style="border-radius: 50px; box-shadow: rgba(122, 122, 122, 0.901961) 0.1em 0.1em 9px; " hspace="10" vspace="10">
<img id="grey" data-color="white" data-colorreal="Серый" src="images/icon_grey.png" style="border-radius: 50px; box-shadow: rgba(122, 122, 122, 0.901961) 0.1em 0.1em 9px;" hspace="10" vspace="10">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question