Show / Hide Table of Contents

Class SVGCanvas

Canvas for generating SVG files.

Inheritance
object
AbstractCanvas
SVGCanvas
Implements
ICanvas
IDisposable
Inherited Members
AbstractCanvas.MmToPt
AbstractCanvas.FontMetrics
AbstractCanvas.SetupFontMetrics(string)
AbstractCanvas.PutTextLines(string[], double, double, int, double)
AbstractCanvas.Ascender(int)
AbstractCanvas.Descender(int)
AbstractCanvas.LineHeight(int)
AbstractCanvas.TextWidth(string, int, bool)
AbstractCanvas.SplitLines(string, double, int)
AbstractCanvas.Dispose()
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Codecrete.SwissQRBill.Generator.Canvas
Assembly: Codecrete.SwissQRBill.Core.dll
Syntax
public class SVGCanvas : AbstractCanvas, ICanvas, IDisposable

Constructors

| Edit this page View Source

SVGCanvas(double, double, string)

Initializes a new SVG canvas with the specified size and font family.

The QR bill will be drawn in the bottom left corner of the SVG image.

Declaration
public SVGCanvas(double width, double height, string fontFamilyList)
Parameters
Type Name Description
double width

The image width, in mm.

double height

The image height, in mm.

string fontFamilyList

A list font family names, separated by comma (same syntax as for CSS).

Methods

| Edit this page View Source

AddRectangle(double, double, double, double)

Adds a rectangle to the open path.

Declaration
public override void AddRectangle(double x, double y, double width, double height)
Parameters
Type Name Description
double x

The rectangle's left position (in mm).

double y

The rectangle's top position (in mm).

double width

The rectangle's width (in mm).

double height

The rectangle's height (in mm).

Overrides
AbstractCanvas.AddRectangle(double, double, double, double)
| Edit this page View Source

Close()

Closes this instance and frees resources.

After a call to this method, the canvas can no longer be used for drawing.

Declaration
protected void Close()
| Edit this page View Source

CloseSubpath()

Closes the current subpath. The next path operation will implicitly open a new subpath.

Declaration
public override void CloseSubpath()
Overrides
AbstractCanvas.CloseSubpath()
| Edit this page View Source

CubicCurveTo(double, double, double, double, double, double)

Adds a cubic BeziƩr curve to the open path going from the previous point to the specified position. Two control points determine the curve.

Declaration
public override void CubicCurveTo(double x1, double y1, double x2, double y2, double x, double y)
Parameters
Type Name Description
double x1

The x-coordinate of first control point.

double y1

The y-coordinate of first control point.

double x2

The x-coordinate of second control point.

double y2

The y-coordinate of second control point.

double x

The x-coordinate of position.

double y

The y-coordinate of position.

Overrides
AbstractCanvas.CubicCurveTo(double, double, double, double, double, double)
| Edit this page View Source

Dispose(bool)

Frees and releases resources.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

indicates whether the method is called from a Dispose method (true) or from a finalizer (false).

Overrides
AbstractCanvas.Dispose(bool)
| Edit this page View Source

FillPath(int, bool)

Fills the current path and discards it.

Declaration
public override void FillPath(int color, bool smoothing = true)
Parameters
Type Name Description
int color

The fill color (expressed similar to HTML, e.g. 0xffffff for white).

bool smoothing

true for using smoothing techniques such as antialiasing, false otherwise

Overrides
AbstractCanvas.FillPath(int, bool)
| Edit this page View Source

LineTo(double, double)

Adds a line segment to the open path from the previous point to the specified position.

Declaration
public override void LineTo(double x, double y)
Parameters
Type Name Description
double x

The x-coordinate of position.

double y

The y-coordinate of position.

Overrides
AbstractCanvas.LineTo(double, double)
| Edit this page View Source

MoveTo(double, double)

Moves the current point of the open path to the specified position.

Declaration
public override void MoveTo(double x, double y)
Parameters
Type Name Description
double x

The x-coordinate of position.

double y

The y-coordinate of position.

Overrides
AbstractCanvas.MoveTo(double, double)
| Edit this page View Source

PutText(string, double, double, int, bool)

Draws text to the canvas.

The text position refers to the left most point on the text's baseline.

Declaration
public override void PutText(string text, double x, double y, int fontSize, bool isBold)
Parameters
Type Name Description
string text

The text to draw.

double x

The x position of the text's start (in mm).

double y

The y position of the text's top (in mm).

int fontSize

The font size (in pt).

bool isBold

Flag indicating if the text is in bold or regular weight.

Overrides
AbstractCanvas.PutText(string, double, double, int, bool)
| Edit this page View Source

SaveAs(string)

Writes the resulting graphics as an SVG image to the specified file path.

The canvas can no longer be used for drawing after calling this method.

Declaration
public void SaveAs(string path)
Parameters
Type Name Description
string path

The path (file name) to write to.

| Edit this page View Source

SetTransformation(double, double, double, double, double)

Sets a translation, rotation and scaling for the subsequent operations.

Before a new translation is applied, the coordinate system is reset to it's original state.

The transformations are applied in the order translation, rotation, scaling.

Declaration
public override void SetTransformation(double translateX, double translateY, double rotate, double scaleX, double scaleY)
Parameters
Type Name Description
double translateX

The translation in x direction (in mm).

double translateY

The translation in y direction (in mm).

double rotate

The rotation angle, in radians.

double scaleX

The scale factor in x direction (1.0 = no scaling).

double scaleY

The scale factor in y direction (1.0 = no scaling).

Overrides
AbstractCanvas.SetTransformation(double, double, double, double, double)
| Edit this page View Source

StartPath()

Starts a path that can be filled or stroked.

Declaration
public override void StartPath()
Overrides
AbstractCanvas.StartPath()
| Edit this page View Source

StrokePath(double, int, LineStyle, bool)

Strokes the current path and discards it.

Declaration
public override void StrokePath(double strokeWidth, int color, LineStyle lineStyle = LineStyle.Solid, bool smoothing = true)
Parameters
Type Name Description
double strokeWidth

The stroke width (in pt).

int color

The stroke color (expressed similar to HTML, e.g. 0xffffff for white).

LineStyle lineStyle

The line style

bool smoothing

true for using smoothing techniques such as antialiasing, false otherwise

Overrides
AbstractCanvas.StrokePath(double, int, LineStyle, bool)
| Edit this page View Source

ToByteArray()

Gets the resulting graphics as an SVG document in a byte array.

The canvas can no longer be used for drawing after calling this method.

Declaration
public override byte[] ToByteArray()
Returns
Type Description
byte[]

The byte array containing the SVG document

Overrides
AbstractCanvas.ToByteArray()
| Edit this page View Source

WriteTo(Stream)

Writes the resulting graphics as an SVG image to the specified stream.

The canvas can no longer be used for drawing after calling this method.

Declaration
public void WriteTo(Stream stream)
Parameters
Type Name Description
Stream stream

The stream to write to.

Implements

ICanvas
IDisposable
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX