Properti Stroke SVG
Properti Stroke SVG
SVG menawarkan berbagai macam properti stroke. Dalam bab ini kita akan melihat hal-hal berikut:
- stroke
- lebar stroke
- stroke-linecap
- stroke-dasharray
Semua properti goresan dapat diterapkan ke segala jenis garis, teks, dan kerangka elemen seperti lingkaran.
SVG stroke Properti
Properti stroke mendefinisikan warna garis, teks atau garis besar elemen:
Berikut adalah kode SVG:
Contoh
<svg height="80" width="300">
<g fill="none">
<path stroke="red" d="M5 20 l215 0" />
<path stroke="black" d="M5 40 l215 0" />
<path stroke="blue" d="M5 60 l215 0" />
</g>
</svg>
Properti lebar stroke SVG
Properti stroke-width mendefinisikan ketebalan garis, teks atau garis besar elemen:
Berikut adalah kode SVG:
Contoh
<svg height="80" width="300">
<g fill="none" stroke="black">
<path stroke-width="2" d="M5 20 l215 0" />
<path stroke-width="4" d="M5 40 l215 0" />
<path stroke-width="6" d="M5 60 l215 0" />
</g>
</svg>
Properti stroke-linecap SVG
Properti stroke-linecap mendefinisikan berbagai jenis akhiran ke jalur terbuka:
Berikut adalah kode SVG:
Contoh
<svg height="80" width="300">
<g fill="none" stroke="black" stroke-width="6">
<path stroke-linecap="butt" d="M5 20 l215 0" />
<path stroke-linecap="round" d="M5 40 l215 0" />
<path stroke-linecap="square" d="M5 60 l215 0" />
</g>
</svg>
Properti stroke-dasharray SVG
Properti stroke-dasharray digunakan untuk membuat garis putus-putus:
Berikut adalah kode SVG:
Contoh
<svg height="80" width="300">
<g fill="none" stroke="black" stroke-width="4">
<path stroke-dasharray="5,5" d="M5 20 l215 0" />
<path stroke-dasharray="10,10" d="M5 40 l215 0" />
<path stroke-dasharray="20,10,5,5,5,10" d="M5 60 l215 0" />
</g>
</svg>