forked from Kinovea/Kinovea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for SVG files using percentage of viewbox in width and height…
… attributes.
- Loading branch information
1 parent
d41dc14
commit 9e4de0d
Showing
3 changed files
with
61 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 41 additions & 46 deletions
87
SharpVectorRenderingEngine/SharpVectors/Renderer/Gdi/SvgElementGraphicsNode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,41 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
using System.Drawing.Drawing2D; | ||
using System.Text.RegularExpressions; | ||
|
||
using SharpVectors.Dom.Svg; | ||
using SharpVectors.Dom.Svg.Rendering; | ||
|
||
namespace SharpVectors.Renderer.Gdi | ||
{ | ||
/// <summary> | ||
/// Summary description for SvgElementGraphicsNode. | ||
/// </summary> | ||
public class SvgElementGraphicsNode : GraphicsNode | ||
{ | ||
#region Constructor | ||
public SvgElementGraphicsNode(SvgElement element) : base(element) | ||
{ | ||
} | ||
#endregion | ||
|
||
#region Public Methods | ||
public override void Render(ISvgRenderer renderer) | ||
{ | ||
GraphicsWrapper graphics = ((GdiRenderer) renderer).GraphicsWrapper; | ||
|
||
SvgSvgElement svgElm = (SvgSvgElement) element; | ||
|
||
float x = (float)svgElm.X.AnimVal.Value; | ||
float y = (float)svgElm.Y.AnimVal.Value; | ||
float width = (float)svgElm.Width.AnimVal.Value; | ||
float height = (float)svgElm.Height.AnimVal.Value; | ||
|
||
RectangleF elmRect = new RectangleF(x, y, width, height); | ||
|
||
if ( element.ParentNode is SvgElement ) | ||
{ | ||
// TODO: should it be moved with x and y? | ||
} | ||
|
||
fitToViewbox(graphics, elmRect); | ||
} | ||
#endregion | ||
} | ||
} | ||
using System; | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
using System.Drawing.Drawing2D; | ||
using System.Text.RegularExpressions; | ||
|
||
using SharpVectors.Dom.Svg; | ||
using SharpVectors.Dom.Svg.Rendering; | ||
|
||
namespace SharpVectors.Renderer.Gdi | ||
{ | ||
/// <summary> | ||
/// Summary description for SvgElementGraphicsNode. | ||
/// </summary> | ||
public class SvgElementGraphicsNode : GraphicsNode | ||
{ | ||
#region Constructor | ||
public SvgElementGraphicsNode(SvgElement element) : base(element) | ||
{ | ||
} | ||
#endregion | ||
|
||
#region Public Methods | ||
public override void Render(ISvgRenderer renderer) | ||
{ | ||
GraphicsWrapper graphics = ((GdiRenderer) renderer).GraphicsWrapper; | ||
|
||
SvgSvgElement svgElm = (SvgSvgElement) element; | ||
|
||
float x = (float)svgElm.X.AnimVal.Value; | ||
float y = (float)svgElm.Y.AnimVal.Value; | ||
float width = (float)svgElm.Width.AnimVal.Value; | ||
float height = (float)svgElm.Height.AnimVal.Value; | ||
|
||
RectangleF elmRect = new RectangleF(x, y, width, height); | ||
|
||
fitToViewbox(graphics, elmRect); | ||
} | ||
#endregion | ||
} | ||
} |