Logo address

Line

2012/11/20

Straight lines and Polygonal lines

あなたのブラウザは SVG をサポートしていません。最新のブラウザをお使いください。

このプログラムのコードは

#encoding: utf-8
import svg
c = svg.Canvas(0,0,600,600)
c.grid(100,100,stroke="cyan")

# simple line
c.line(50,50,250,50)
c.line(300,50,500,50,stroke="width:5")

# polyline
c.line(50,100,250,100,300,150,500,100,stroke="width:5")

# polyline with marker
p = c.marker("triangle")
c.line(50,150,250,150,300,200,500,150,stroke="width:5",marker="end:"+p)
c.line(50,200,250,200,300,250,500,200,stroke="width:5",marker="start:"+p)
c.line(50,250,250,250,300,300,500,250,stroke="width:5",marker="mid:"+p)
q = c.marker("arrow")
c.line(50,300,150,300,250,300,stroke="width:5",marker="mid:"+q)

# dasharray
c.line(50,350,250,350,stroke="width:5;dasharray:10 10")
c.line(300,350,450,350,stroke="width:5;dasharray:15 5 5 5")

# linecap
c.line(50,400,100,400,stroke="width:20;linecap:butt")
c.line(50,450,100,450,stroke="width:20;linecap:round")
c.line(50,500,100,500,stroke="width:20;linecap:square")

# linejoin
c.line(150,450,200,400,250,450,stroke="width:20;linejoin:miter")
c.line(300,450,350,400,400,450,stroke="width:20;linejoin:round")
c.line(450,450,500,400,550,450,stroke="width:20;linejoin:bevel")

# opacity
c.circle(300,520,r=50,fill="red",stroke="red")
c.line(200,520,300,520,stroke="width:20;opacity:0.3")

# fill
c.line(450,550,450,500,550,500,550,550,stroke="black;width:10",fill="red")

c.close()