Unverified Commit 2a8ea670 authored by mrbean-bremen's avatar mrbean-bremen
Browse files

Consider transformation in marker path

- transformations in the marker drawing element have been ignored
- fixes #215
parent 6f96b730
......@@ -10,6 +10,22 @@ namespace Svg
public class SvgMarker : SvgPathBasedElement, ISvgViewPort
{
private SvgOrient _svgOrient = new SvgOrient();
private SvgVisualElement _markerElement = null;
/// <summary>
/// Return the child element that represent the marker
/// </summary>
private SvgVisualElement MarkerElement
{
get
{
if (_markerElement == null)
{
_markerElement = (SvgVisualElement)this.Children.FirstOrDefault(x => x is SvgVisualElement);
}
return _markerElement;
}
}
[SvgAttribute("refX")]
public virtual SvgUnit RefX
......@@ -86,11 +102,8 @@ namespace Svg
{
get
{
var path = this.Children.FirstOrDefault(x => x is SvgVisualElement);
if (path != null)
{
return path.Fill;
}
if (MarkerElement != null)
return MarkerElement.Fill;
return base.Fill;
}
}
......@@ -100,12 +113,10 @@ namespace Svg
/// </summary>
public override SvgPaintServer Stroke
{
get {
var path = this.Children.FirstOrDefault(x => x is SvgVisualElement);
if (path != null)
{
return path.Stroke;
}
get
{
if (MarkerElement != null)
return MarkerElement.Stroke;
return base.Stroke;
}
}
......@@ -120,9 +131,8 @@ namespace Svg
public override System.Drawing.Drawing2D.GraphicsPath Path(ISvgRenderer renderer)
{
var path = this.Children.FirstOrDefault(x => x is SvgVisualElement);
if (path != null)
return (path as SvgVisualElement).Path(renderer);
if (MarkerElement != null)
return MarkerElement.Path(renderer);
return null;
}
......@@ -235,6 +245,14 @@ namespace Svg
-RefY.ToDeviceValue(pRenderer, UnitRenderingType.Vertical, this));
break;
}
if (MarkerElement != null && MarkerElement.Transforms != null)
{
foreach (var transformation in MarkerElement.Transforms)
{
transMatrix.Multiply(transformation.Matrix);
}
}
markerPath.Transform(transMatrix);
if (pRenderPen != null) pRenderer.DrawPath(pRenderPen, markerPath);
......
......@@ -179,6 +179,7 @@ __issue-143-01
__issue-191-01
__issue-202-01
__issue-214-01
__issue-215-01
__issue-227-01
__issue-227-02
__issue-239-01
......
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="300" version="1.1" width="400" style="overflow: hidden; position: relative;">
<path fill="none" stroke="#000000" d="M161,97C177.5,97,194,154,194,211" marker-end="url(#raphael-marker-endopen55-obj18)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" />
<path fill="none" stroke="#000000" d="M161,97C223,97,223,107,285,107" marker-end="url(#raphael-marker-endopen55-obj13)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" />
<desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.2.0</desc>
<defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
<path stroke-linecap="round" d="M6,1 1,3.5 6,6" id="raphael-marker-open" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" />
<marker id="raphael-marker-endopen55-obj13" markerHeight="5" markerWidth="5" orient="auto" refX="4" refY="2.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
<use xlink:href="#raphael-marker-open" transform="rotate(180 2.5 2.5) scale(0.7142857142857143,0.7142857142857143)" stroke-width="1.4000" fill="none" stroke="#000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" />
</marker>
<marker id="raphael-marker-endopen55-obj18" markerHeight="5" markerWidth="5" orient="auto" refX="4" refY="2.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
<use xlink:href="#raphael-marker-open" transform="rotate(180 2.5 2.5) scale(0.7142857142857143,0.7142857142857143)" stroke-width="1.4000" fill="none" stroke="#000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" />
</marker>
</defs>
<rect x="90" y="82" width="70" height="30" rx="5" ry="5" fill="#00b050" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: move;" />
<text x="125" y="97" text-anchor="middle" font-family="&quot;Arial&quot;" font-size="12px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font-family: Arial; font-size: 12px;">
<tspan dy="4" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Main</tspan>
</text>
<rect x="153" y="90" width="14" height="14" rx="3" ry="3" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer;" />
<text x="160" y="97" text-anchor="middle" font-family="&quot;Arial&quot;" font-size="10px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font-family: Arial; font-size: 10px; cursor: pointer;">
<tspan dy="3.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">+</tspan>
</text>
<rect x="286" y="92" width="70" height="30" rx="5" ry="5" fill="#00b050" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: move;" />
<text x="321" y="107" text-anchor="middle" font-family="&quot;Arial&quot;" font-size="12px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font-family: Arial; font-size: 12px;">
<tspan dy="4" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Child</tspan>
</text>
<rect x="349" y="100" width="14" height="14" rx="3" ry="3" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer;" />
<text x="356" y="107" text-anchor="middle" font-family="&quot;Arial&quot;" font-size="10px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font-family: Arial; font-size: 10px; cursor: pointer;">
<tspan dy="3.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">+</tspan>
</text>
<rect x="159" y="212" width="70" height="30" rx="5" ry="5" fill="#ff0000" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: move;" />
<text x="194" y="227" text-anchor="middle" font-family="&quot;Arial&quot;" font-size="12px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font-family: Arial; font-size: 12px;">
<tspan dy="4" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Child</tspan>
</text>
<rect x="222" y="220" width="14" height="14" rx="3" ry="3" fill="#ffffff" stroke="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer;" />
<text x="229" y="227" text-anchor="middle" font-family="&quot;Arial&quot;" font-size="10px" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font-family: Arial; font-size: 10px; cursor: pointer;">
<tspan dy="3.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">+</tspan>
</text>
</svg>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment