Properti Garis SVG
- Hal Sebelumnya Teks SVG
- Hal Berikutnya Filter SVG
Properti Garis SVG
SVG menyediakan berbagai properti garis. Dalam bab ini, kita akan membahas tentang hal berikut:
stroke
stroke-width
stroke-linecap
stroke-dasharray
Semua properti garis dapat digunakan untuk semua jenis garis, teks dan kontur elemen (seperti lingkaran).
Atribut stroke SVG
stroke
Atribut mendefinisikan warna kontur garis, teks, atau elemen:
Ini adalah kode SVG:
<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>
Atribut stroke-width SVG
stroke-width
Atribut mendefinisikan ketebalan kontur garis, teks, atau elemen:
Ini adalah kode SVG:
<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>
Atribut stroke-linecap SVG
stroke-linecap
Atribut mendefinisikan jenis ujung jalur yang terbuka:
Ini adalah kode SVG:
<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>
Atribut stroke-dasharray SVG
stroke-dasharray
Atribut digunakan untuk membuat garis berdasi:
Ini adalah kode SVG:
<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>
- Hal Sebelumnya Teks SVG
- Hal Berikutnya Filter SVG