HTML nieruchomość płótno strokeStyle
HTML Instrukcja płótno referencyjny
Przykłady
Narysuj prostokąt. Kolor czerwony z udarem:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.strokeStyle="#FF0000";
ctx.strokeRect(20,20,150,100);
var ctx=c.getContext("2d");
ctx.strokeStyle="#FF0000";
ctx.strokeRect(20,20,150,100);
Spróbuj »
Pomoc Browser
Internet Explorer 9, Firefox, Opera, Chrome i Safari obsługa nieruchomości strokeStyle.
Uwaga: 8 i wcześniejsze wersje programu Internet Explorer nie obsługuje <canvas> elementu.
Definicja i Wykorzystanie
strokeStyle zestawy własności lub zwraca kolor, gradient lub wzór dla udaru mózgu.
Domyślnie: | # 000000 |
---|---|
Składnia JavaScript: | Kontekst .strokeStyle = kolor | Gradient | wzór; |
Wartość nieruchomości
值 | 描述 |
---|---|
color | 指示绘图笔触颜色的 CSS 颜色值 。默认值是 #000000。 |
gradient | 用于填充绘图的渐变对象( 线性 或 放射性 )。 |
pattern | 用于创建 pattern 笔触的 pattern 对象。 |
Więcej przykładów
Przykłady
Narysuj prostokąt. Użyj udar gradient:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var gradient=ctx.createLinearGradient(0,0,170,0);
gradient.addColorStop("0","magenta");
gradient.addColorStop("0.5","blue");
gradient.addColorStop("1.0","red");
// Fill with gradient
ctx.strokeStyle=gradient;
ctx.lineWidth=5;
ctx.strokeRect(20,20,150,100);
var ctx=c.getContext("2d");
var gradient=ctx.createLinearGradient(0,0,170,0);
gradient.addColorStop("0","magenta");
gradient.addColorStop("0.5","blue");
gradient.addColorStop("1.0","red");
// Fill with gradient
ctx.strokeStyle=gradient;
ctx.lineWidth=5;
ctx.strokeRect(20,20,150,100);
Spróbuj »
Przykłady
Z gradientem udaru napisać tekst "Duży uśmiech!":
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="30px Verdana";
// Create gradient
var gradient=ctx.createLinearGradient(0,0,c.width,0);
gradient.addColorStop("0","magenta");
gradient.addColorStop("0.5","blue");
gradient.addColorStop("1.0","red");
// Fill with gradient
ctx.strokeStyle=gradient;
ctx.strokeText("Big smile!",10,50);
var ctx=c.getContext("2d");
ctx.font="30px Verdana";
// Create gradient
var gradient=ctx.createLinearGradient(0,0,c.width,0);
gradient.addColorStop("0","magenta");
gradient.addColorStop("0.5","blue");
gradient.addColorStop("1.0","red");
// Fill with gradient
ctx.strokeStyle=gradient;
ctx.strokeText("Big smile!",10,50);
Spróbuj »
HTML Instrukcja płótno referencyjny