Skip to content

Commit

Permalink
Support marker-start
Browse files Browse the repository at this point in the history
  • Loading branch information
fathat committed Mar 17, 2013
1 parent bfb346f commit 214c7b0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 70 deletions.
27 changes: 18 additions & 9 deletions glsvg/svg_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,31 @@ def _render_stroke(self):
join_type=self.style.stroke_linejoin,
miter_limit=miter_limit)

if self.marker_start:
end_point = vec2(loop_plus[0])
almost_end_point = vec2(loop_plus[1])
marker = self.svg.defs[self.marker_start]
self._render_marker(end_point, almost_end_point, marker)
if self.marker_end:
end_point = vec2(loop_plus[-1])
almost_end_point = vec2(loop_plus[-2])
angle = (end_point - almost_end_point).angle()
marker = self.svg.defs[self.marker_end]
sx = (marker.marker_width / marker.vb_w) * self.style.stroke_width
sy = (marker.marker_height / marker.vb_h) * self.style.stroke_width
self._render_marker(end_point, almost_end_point, marker)

rx = marker.ref_x
ry = marker.ref_y
def _render_marker(self, a, b, marker):
angle = (a - b).angle()

sx = (marker.marker_width / marker.vb_w) * self.style.stroke_width
sy = (marker.marker_height / marker.vb_h) * self.style.stroke_width

with Matrix.transform(end_point.x, end_point.y, theta=angle):
with Matrix.scale(sx, sy):
with Matrix.translation(-rx, -ry):
marker.render()
rx = marker.ref_x
ry = marker.ref_y


with Matrix.transform(a.x, a.y, theta=angle):
with Matrix.scale(sx, sy):
with Matrix.translation(-rx, -ry):
marker.render()

def _render_gradient_fill(self):
fill = self.style.fill
Expand Down
74 changes: 13 additions & 61 deletions svgs/0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 214c7b0

Please sign in to comment.