From: Marius Gedminas <marius@gedmin.as>
... | ... |
@@ -59,6 +59,7 @@ class Pen: |
59 | 59 |
self.linewidth = 1.0 |
60 | 60 |
self.fontsize = 14.0 |
61 | 61 |
self.fontname = "Times-Roman" |
62 |
+ self.dash = () |
|
62 | 63 |
|
63 | 64 |
def copy(self): |
64 | 65 |
"""Create a copy of this pen.""" |
... | ... |
@@ -196,6 +197,7 @@ class EllipseShape(Shape): |
196 | 197 |
cr.set_source_rgba(*self.pen.fillcolor) |
197 | 198 |
cr.fill() |
198 | 199 |
else: |
200 |
+ cr.set_dash(self.pen.dash) |
|
199 | 201 |
cr.set_line_width(self.pen.linewidth) |
200 | 202 |
cr.set_source_rgba(*self.pen.color) |
201 | 203 |
cr.stroke() |
... | ... |
@@ -220,6 +222,7 @@ class PolygonShape(Shape): |
220 | 222 |
cr.fill_preserve() |
221 | 223 |
cr.fill() |
222 | 224 |
else: |
225 |
+ cr.set_dash(self.pen.dash) |
|
223 | 226 |
cr.set_line_width(self.pen.linewidth) |
224 | 227 |
cr.set_source_rgba(*self.pen.color) |
225 | 228 |
cr.stroke() |
... | ... |
@@ -240,6 +243,7 @@ class BezierShape(Shape): |
240 | 243 |
x2, y2 = self.points[i + 1] |
241 | 244 |
x3, y3 = self.points[i + 2] |
242 | 245 |
cr.curve_to(x1, y1, x2, y2, x3, y3) |
246 |
+ cr.set_dash(self.pen.dash) |
|
243 | 247 |
cr.set_line_width(self.pen.linewidth) |
244 | 248 |
cr.set_source_rgba(*self.pen.color) |
245 | 249 |
cr.stroke() |
... | ... |
@@ -471,6 +475,8 @@ class XDotAttrParser: |
471 | 475 |
if style.startswith("setlinewidth("): |
472 | 476 |
lw = style.split("(")[1].split(")")[0] |
473 | 477 |
pen.linewidth = float(lw) |
478 |
+ elif style == "dashed": |
|
479 |
+ pen.dash = [6] # 6pt on, 6pt off |
|
474 | 480 |
elif op == "F": |
475 | 481 |
pen.fontsize = s.read_float() |
476 | 482 |
pen.fontname = s.read_text() |