Commit 27a276d9 authored by davescriven's avatar davescriven
Browse files

- Fixed #6156: Optional second parameter for scale transform not supported.

parent d5c84b66
...@@ -25,6 +25,9 @@ namespace Svg ...@@ -25,6 +25,9 @@ namespace Svg
set { this.Attributes["Visible"] = value; } set { this.Attributes["Visible"] = value; }
} }
/// <summary>
/// Gets or sets the fill <see cref="SvgPaintServer"/> of this element.
/// </summary>
[SvgAttribute("fill")] [SvgAttribute("fill")]
public virtual SvgPaintServer Fill public virtual SvgPaintServer Fill
{ {
...@@ -32,6 +35,9 @@ namespace Svg ...@@ -32,6 +35,9 @@ namespace Svg
set { this.Attributes["Fill"] = value; } set { this.Attributes["Fill"] = value; }
} }
/// <summary>
/// Gets or sets the <see cref="SvgPaintServer"/> to be used when rendering a stroke around this element.
/// </summary>
[SvgAttribute("stroke")] [SvgAttribute("stroke")]
public virtual SvgPaintServer Stroke public virtual SvgPaintServer Stroke
{ {
...@@ -46,6 +52,9 @@ namespace Svg ...@@ -46,6 +52,9 @@ namespace Svg
set { this.Attributes["FillRule"] = value; } set { this.Attributes["FillRule"] = value; }
} }
/// <summary>
/// Gets or sets the opacity of this element's <see cref="Fill"/>.
/// </summary>
[SvgAttribute("fill-opacity")] [SvgAttribute("fill-opacity")]
public virtual float FillOpacity public virtual float FillOpacity
{ {
......
...@@ -26,12 +26,6 @@ namespace Svg ...@@ -26,12 +26,6 @@ namespace Svg
get { return new SvgPoint(X, Y); } get { return new SvgPoint(X, Y); }
} }
public override SvgPaintServer Fill
{
get { return (this.Attributes["Fill"] == null) ? new SvgColourServer(Color.Black) : (SvgPaintServer)this.Attributes["Fill"]; }
set { this.Attributes["Fill"] = value; }
}
[SvgAttribute("x")] [SvgAttribute("x")]
public SvgUnit X public SvgUnit X
{ {
......
...@@ -2,25 +2,52 @@ using System; ...@@ -2,25 +2,52 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml; using System.Xml;
using System.Text; using System.Text;
using System.Drawing;
namespace Svg namespace Svg
{ {
/// <summary>
/// An element used to group SVG shapes.
/// </summary>
public class SvgGroup : SvgGraphicsElement public class SvgGroup : SvgGraphicsElement
{ {
public SvgGroup() public SvgGroup()
{ {
} }
/// <summary>
/// Gets or sets the fill.
/// </summary>
/// <value>The fill.</value>
[SvgAttribute("fill")]
public override SvgPaintServer Fill
{
get { return (this.Attributes["Fill"] == null) ? new SvgColourServer(Color.Transparent) : (SvgPaintServer)this.Attributes["Fill"]; }
set { this.Attributes["Fill"] = value; }
}
/// <summary>
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
/// <value></value>
public override System.Drawing.Drawing2D.GraphicsPath Path public override System.Drawing.Drawing2D.GraphicsPath Path
{ {
get { return null; } get { return null; }
} }
/// <summary>
/// Gets the bounds of the element.
/// </summary>
/// <value>The bounds.</value>
public override System.Drawing.RectangleF Bounds public override System.Drawing.RectangleF Bounds
{ {
get { return new System.Drawing.RectangleF(); } get { return new System.Drawing.RectangleF(); }
} }
/// <summary>
/// Renders the <see cref="SvgElement"/> and contents to the specified <see cref="Graphics"/> object.
/// </summary>
/// <param name="graphics">The <see cref="Graphics"/> object to render to.</param>
protected override void Render(System.Drawing.Graphics graphics) protected override void Render(System.Drawing.Graphics graphics)
{ {
this.PushTransforms(graphics); this.PushTransforms(graphics);
......
...@@ -7,7 +7,7 @@ namespace Svg ...@@ -7,7 +7,7 @@ namespace Svg
{ {
public sealed class SvgColourServer : SvgPaintServer public sealed class SvgColourServer : SvgPaintServer
{ {
public SvgColourServer() : this(Color.Transparent) public SvgColourServer() : this(Color.Black)
{ {
} }
......
...@@ -10,7 +10,7 @@ namespace Svg ...@@ -10,7 +10,7 @@ namespace Svg
[TypeConverter(typeof(SvgPaintServerFactory))] [TypeConverter(typeof(SvgPaintServerFactory))]
public abstract class SvgPaintServer : SvgElement public abstract class SvgPaintServer : SvgElement
{ {
public static readonly SvgPaintServer None = new SvgColourServer(Color.Transparent); public static readonly SvgPaintServer None = new SvgColourServer();
public SvgPaintServer() public SvgPaintServer()
{ {
......
...@@ -58,6 +58,12 @@ namespace Svg.Transforms ...@@ -58,6 +58,12 @@ namespace Svg.Transforms
{ {
case "translate": case "translate":
string[] coords = contents.Split(new char[]{',', ' '}, StringSplitOptions.RemoveEmptyEntries); string[] coords = contents.Split(new char[]{',', ' '}, StringSplitOptions.RemoveEmptyEntries);
if (coords.Length != 2)
{
throw new FormatException("Translate transforms must be in the format 'translate(x, y)'");
}
float x = float.Parse(coords[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture); float x = float.Parse(coords[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
float y = float.Parse(coords[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture); float y = float.Parse(coords[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
transformList.Add(new SvgTranslate(x, y)); transformList.Add(new SvgTranslate(x, y));
...@@ -67,8 +73,25 @@ namespace Svg.Transforms ...@@ -67,8 +73,25 @@ namespace Svg.Transforms
transformList.Add(new SvgRotate(angle)); transformList.Add(new SvgRotate(angle));
break; break;
case "scale": case "scale":
float scaleFactor = float.Parse(contents, NumberStyles.Float, CultureInfo.InvariantCulture); string[] scales = contents.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
transformList.Add(new SvgScale(scaleFactor));
if (scales.Length == 0 || scales.Length > 2)
{
throw new FormatException("Scale transforms must be in the format 'scale(x [,y])'");
}
float sx = float.Parse(scales[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
if (scales.Length > 1)
{
float sy = float.Parse(scales[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
transformList.Add(new SvgScale(sx, sy));
}
else
{
transformList.Add(new SvgScale(sx));
}
break; break;
} }
} }
......
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