2009-09-14 12 views

Odpowiedz

31

użytkowania strokeText() a strokeStyle. np

canvas = document.getElementById("myc"); 
 
context = canvas.getContext('2d'); 
 

 
context.fillStyle = 'red'; 
 
context.strokeStyle = 'black'; 
 

 
context.font = '20pt Verdana'; 
 
context.fillText('Some text', 50, 50); 
 
context.strokeText('Some text', 50, 50); 
 

 
context.fill(); 
 
context.stroke();
<canvas id="myc"></canvas>

+0

wao! Nigdy wcześniej nie widziałem tak "wykonalnej" odpowiedzi w SO. Czy to nowa funkcja? – Samiron

-1

Co

myCanvas.style.border = "red 1px solid"; 
+15

Dodaje obramowanie na płótnie - nie do tekstu opracowanego w płótnie; Zakładam, że op chce stworzyć granicę w kształcie samych liter. – dionyziz

4

Możemy użyć strokeStyle sposób narysować ramkę wokół tekstu lub szkicu, a Możemy użyć lineWidth metoda definiowania szerokości linii obrysu.

<script> 
    var canvas = document.getElementById('Canvas01'); 
    var ctx = canvas.getContext('2d'); 

    ctx.strokeStyle= "red"; //set the color of the stroke line 
    ctx.lineWidth = 3; //define the width of the stroke line 
    ctx.font = "italic bold 35pt Tahoma"; //set the font name and font size 
    ctx.strokeText("StackOverFlow",30,80); //draw the text 

</script> 
</body> 
Powiązane problemy