views:

1005

answers:

2

I can draw text using these code:

   myCanvas.fillStyle = "Red";

   myCanvas.font = "30pt Arial";
   myCanvas.fillText("Some Text", 10, 30);

I want to add a border around "Some Text", any ideas on that?

A: 

What about

myCanvas.style.border = "red 1px solid";
rahul
+1  A: 

Use strokeText() and the strokeStyle. eg:

<canvas id="myc"></canvas>

<script>
    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();
</script>
Richard Heyes