Método HTML canvas strokeRect()
Ejemplo
Dibuja un rectángulo de 150*100 píxeles:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.strokeRect(20, 20, 150, 100);
Compatibilidad con navegador
Los números en la tabla especifican la primera versión del navegador que soporta totalmente este método.
Method | |||||
---|---|---|---|---|---|
strokeRect() | 4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Definición y uso
El método strokeRect() dibuja un rectángulo (sin relleno). El color predeterminado del trazo es negro.
Sugerencia: use la propiedad strokeStyle para establecer un color, degradado o patrón para aplicar estilo al trazo.
Sintaxis de JavaScript: | contexto .strokeRect( x, y, ancho, alto ); |
---|
Valores paramétricos
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of the upper-left corner of the rectangle | |
y | The y-coordinate of the upper-left corner of the rectangle | |
width | The width of the rectangle, in pixels | |
height | The height of the rectangle, in pixels |
❮ Objeto de lienzo