ใน Python จะใช้โมดูลที่มีชื่อว่า svgwrite ซึ่งเป็นโมดูลสำหรับใช้สร้างไฟล์ svg ใช้ MIT License
การติดตั้งโมดูล svgwrite
สามารถติดตั้งได้ง่าย ๆ โดยใช้คำสั่ง pip
pip install svgwriteตัวอย่างการใช้งานโมดูล svgwrite
import svgwrite
svg = svgwrite.Drawing(filename = "test-svgwrite.svg",size =("400px", "200px"))
svg.add(svg.rect(insert = (0, 0),size = ("200px","100px"),stroke_width = "5",stroke = "red",fill = "rgb(255,255,188)"))
svg.add(svg.text("สวัสดี SVG :)",insert = (210, 110)))
svg.save()
ผลลัพธ์ไฟล์ test-svgwrite.svg
นอกจากนั้นยังมีตัวอย่างการใช้งานโมดูลนี้ เพิ่มเติมที่ http://bit.ly/python_svgwrite
เอกสารการใช้งานโมดูล svgwrite http://pythonhosted.org//svgwrite/
ติดตามบทความต่อไปนะครับ
ขอบคุณครับ

0 ความคิดเห็น:
แสดงความคิดเห็น
แสดงความคิดเห็นได้ครับ :)