how to change the text color with canvas

1

I draw a string with canvas in this way:

    pdf.setFont("Helvetica", 16)
    # Dibujamos una cadena en la ubicación X,Y especificada
    pdf.drawString(230, 780, u"Contrato de CubanCloud")

I want to know how to change the color that by default is black.

    
asked by Roberto Cárdenas 08.05.2017 в 18:25
source

1 answer

3

Although it is very basic, here is the code.

var canvas= document.getElementById("miCanvas");
var context = canvas.getContext("2d");

context.font = "30px Comic Sans MS";
context.fillStyle = "red";
context.textAlign = "center";
context.fillText("Hello World", canvas.width/2, canvas.height/2); 
<canvas id="miCanvas" width="250px" height="250px"></canvas>
    
answered by 08.05.2017 в 18:41