คุณสมบัติสีของเส้นใน SVG
- หน้าก่อน ข้อความ SVG
- หน้าต่อไป ฟิลเตอร์ SVG
คุณสมบัติสีของเส้นใน SVG
SVG มีคุณสมบัติลายทางที่หลากหลายโดยมาก ในบทนี้เราจะหารือเรื่องต่อไปนี้:
stroke
stroke-width
stroke-linecap
stroke-dasharray
ทั้งหมดคุณสมบัติลายทางสามารถใช้สำหรับรูปแบบของสายทุกชนิด ข้อความและขอบขององค์ประกอบ (เช่นวงกลม)。
ตัวแปร stroke ของ SVG
stroke
ตัวแปรนี้กำหนดสีของลักษณะด้านขอบของเส้น, ข้อความหรือองค์ประกอบอื่น:
นี่คือรหัส 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>
ตัวแปร stroke-width ของ SVG
stroke-width
ตัวแปรนี้กำหนดความหนาของเส้นทาง, ข้อความหรือองค์ประกอบอื่นที่มีลักษณะด้านขอบ:
นี่คือรหัส 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>
ตัวแปร stroke-linecap ของ SVG
stroke-linecap
ตัวแปรนี้กำหนดปลายของเส้นทางที่เปิดตัว:
นี่คือรหัส 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>
ตัวแปร stroke-dasharray ของ SVG
stroke-dasharray
ตัวแปรใช้สร้างสายลายแบบแยกตัว:
นี่คือรหัส 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>
- หน้าก่อน ข้อความ SVG
- หน้าต่อไป ฟิลเตอร์ SVG