VectSharp  2.2.1
A light library for C# vector graphics
VectSharp.Canvas.SKMultiLayerRenderCanvas Class Reference

Represents a multi-threaded, triple-buffered canvas on which the image is drawn using SkiaSharp. More...

Inheritance diagram for VectSharp.Canvas.SKMultiLayerRenderCanvas:

Public Member Functions

 SKMultiLayerRenderCanvas (Document document, Colour backgroundColour, double width, double height, List< SKRenderAction > layerTransforms=null)
 Create a new SKMultiLayerRenderCanvas from a Document, where each page represents a layer. More...
 
 SKMultiLayerRenderCanvas (IEnumerable< Page > layers, Colour backgroundColour, double width, double height, List< SKRenderAction > layerTransforms=null)
 Create a new SKMultiLayerRenderCanvas from a collection of Pages, each representing a layer. More...
 
 SKMultiLayerRenderCanvas (List< SKRenderContext > contents, List< SKRenderAction > contentTransforms, Colour backgroundColour, double width, double height)
 Create a new SKMultiLayerRenderCanvas from a list of SKRenderContexts, each representing a layer. More...
 
void UpdateWith (List< SKRenderContext > contents, List< SKRenderAction > contentTransforms, Colour backgroundColour, double width, double height)
 Replace the contents of the SKMultiLayerRenderCanvas with the specified layers. More...
 
void UpdateLayer (int layer, SKRenderContext newContent, SKRenderAction newTransform)
 Replace a single layer with the specified content. More...
 
void AddLayer (SKRenderContext newContent, SKRenderAction newTransform)
 Add a new layer to the image. More...
 
void InsertLayer (int index, SKRenderContext newContent, SKRenderAction newTransform)
 Insert a new layer at the specified index. More...
 
void RemoveLayer (int layer)
 Remove the specified layer from the image. More...
 
void SwitchLayers (int layer1, int layer2)
 Switch the position of the two specified layers. More...
 
void MoveLayer (int oldIndex, int newIndex)
 Move the specified layer to the specified position, shifting all other layers as necessary. More...
 
RenderTargetBitmap RenderAtResolution (int width, int height, SKColor? background=null)
 Render the image at to a bitmap at the specified resolution. More...
 
void InvalidateDirty ()
 Invalidate the contents of the canvas, forcing it to redraw itself. More...
 
void InvalidateZIndex ()
 Invalidate the contents of the canvas, specifying that the order of the layers has changed. More...
 
override void Render (DrawingContext context)
 
void Dispose ()
 

Public Attributes

List< List< SKRenderAction > > RenderActions
 The list of render actions, each element in this list is itself a list, containing the actions that correspond to a layer in the image. More...
 
List< SKRenderActionLayerTransforms
 The list of transforms associated with each layer. More...
 
object RenderLock = new object()
 An lock for the rendering loop. The public methods of this class already lock on this, but you may need it if you want to directly manipulate the contents of the canvas. More...
 

Properties

double PageWidth [get, set]
 The width of the page that is rendered on this canvas. More...
 
double PageHeight [get, set]
 The height of the page that is rendered on this canvas. More...
 
Func< long, Bitmap > Spinner = null [get, set]
 If the image to draw is not already cached, this method is called with an argument containing the number of milliseconds since the image was last rendered. The method can return a Bitmap that will be drawn on the canvas in order to let users know that the image is being rendered in background. More...
 

Detailed Description

Represents a multi-threaded, triple-buffered canvas on which the image is drawn using SkiaSharp.

Definition at line 43 of file SKMultiLayerRenderCanvas.cs.

Constructor & Destructor Documentation

◆ SKMultiLayerRenderCanvas() [1/3]

VectSharp.Canvas.SKMultiLayerRenderCanvas.SKMultiLayerRenderCanvas ( Document  document,
Colour  backgroundColour,
double  width,
double  height,
List< SKRenderAction layerTransforms = null 
)

Create a new SKMultiLayerRenderCanvas from a Document, where each page represents a layer.

Parameters
documentThe document containing the layers as Pages.
layerTransformsA list of transforms associated with each layer. This list should contain the same number of elements as the number of pages in document . This is useful to manipulate the position of each layer individually. If this is null, an identity transform is applied to each layer.
backgroundColourThe background colour of the canvas.
widthThe width of the canvas and the pages it contains.
heightThe height of the canvas and the pages it contains.

Definition at line 98 of file SKMultiLayerRenderCanvas.cs.

◆ SKMultiLayerRenderCanvas() [2/3]

VectSharp.Canvas.SKMultiLayerRenderCanvas.SKMultiLayerRenderCanvas ( IEnumerable< Page layers,
Colour  backgroundColour,
double  width,
double  height,
List< SKRenderAction layerTransforms = null 
)

Create a new SKMultiLayerRenderCanvas from a collection of Pages, each representing a layer.

Parameters
layersThe contents of the canvas. Each element in this list represents a layer.
layerTransformsA list of transforms associated with each layer. This list should contain the same number of elements as layers . This is useful to manipulate the position of each layer individually. If this is null, an identity transform is applied to each layer.
backgroundColourThe background colour of the canvas.
widthThe width of the canvas and the pages it contains.
heightThe height of the canvas and the pages it contains.

Definition at line 108 of file SKMultiLayerRenderCanvas.cs.

◆ SKMultiLayerRenderCanvas() [3/3]

VectSharp.Canvas.SKMultiLayerRenderCanvas.SKMultiLayerRenderCanvas ( List< SKRenderContext contents,
List< SKRenderAction contentTransforms,
Colour  backgroundColour,
double  width,
double  height 
)

Create a new SKMultiLayerRenderCanvas from a list of SKRenderContexts, each representing a layer.

Parameters
contentsThe contents of the canvas. Each element in this list represents a layer. A Page can be converded to a SKRenderContext through the CopyToSKRenderContext method.
contentTransformsA list of transforms associated with each layer. This list should contain the same number of elements as contents . This is useful to manipulate the position of each layer individually.
backgroundColourThe background colour of the canvas.
widthThe width of the canvas and the page it contains.
heightThe height of the canvas and the page it contains.

Definition at line 143 of file SKMultiLayerRenderCanvas.cs.

Member Function Documentation

◆ AddLayer()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.AddLayer ( SKRenderContext  newContent,
SKRenderAction  newTransform 
)

Add a new layer to the image.

Parameters
newContentThe contents of the new layer. A Page can be converded to a SKRenderContext through the CopyToSKRenderContext method.
newTransformThe transform for the new layer.

Definition at line 276 of file SKMultiLayerRenderCanvas.cs.

◆ InsertLayer()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.InsertLayer ( int  index,
SKRenderContext  newContent,
SKRenderAction  newTransform 
)

Insert a new layer at the specified index.

Parameters
indexThe position at which the new layer will be inserted.
newContentThe contents of the new layer.
newTransformThe transform for the new layer.

Definition at line 309 of file SKMultiLayerRenderCanvas.cs.

◆ InvalidateDirty()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.InvalidateDirty ( )

Invalidate the contents of the canvas, forcing it to redraw itself.

Definition at line 988 of file SKMultiLayerRenderCanvas.cs.

◆ InvalidateZIndex()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.InvalidateZIndex ( )

Invalidate the contents of the canvas, specifying that the order of the layers has changed.

Definition at line 997 of file SKMultiLayerRenderCanvas.cs.

◆ MoveLayer()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.MoveLayer ( int  oldIndex,
int  newIndex 
)

Move the specified layer to the specified position, shifting all other layers as necessary.

Parameters
oldIndexThe current index of the layer to move.
newIndexThe final index of the layer. Layers after this will be shifted by 1 in order to accommodate the moved layer.

Definition at line 389 of file SKMultiLayerRenderCanvas.cs.

◆ RemoveLayer()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.RemoveLayer ( int  layer)

Remove the specified layer from the image.

Parameters
layerThe index of the layer to remove.

Definition at line 340 of file SKMultiLayerRenderCanvas.cs.

◆ RenderAtResolution()

RenderTargetBitmap VectSharp.Canvas.SKMultiLayerRenderCanvas.RenderAtResolution ( int  width,
int  height,
SKColor?  background = null 
)

Render the image at to a bitmap at the specified resolution.

Parameters
widthThe width of the rendered image. Note that the actual width of the returned image might be lower than this, depending on the aspect ratio of the image.
heightThe height of the rendered image. Note that the actual height of the returned image might be lower than this, depending on the aspect ratio of the image.
backgroundThe background colour for the image. If this is null, the current background colour is used.
Returns
A RenderTargetBitmap containing the image rendered at the specified resolution.

Definition at line 735 of file SKMultiLayerRenderCanvas.cs.

◆ SwitchLayers()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.SwitchLayers ( int  layer1,
int  layer2 
)

Switch the position of the two specified layers.

Parameters
layer1The index of the first layer to switch.
layer2The index of the second layer to switch.

Definition at line 364 of file SKMultiLayerRenderCanvas.cs.

◆ UpdateLayer()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.UpdateLayer ( int  layer,
SKRenderContext  newContent,
SKRenderAction  newTransform 
)

Replace a single layer with the specified content.

Parameters
layerThe index of the layer to replace.
newContentThe new contents of the layer. A Page can be converded to a SKRenderContext through the CopyToSKRenderContext method.
newTransformThe new transform for the layer.

Definition at line 244 of file SKMultiLayerRenderCanvas.cs.

◆ UpdateWith()

void VectSharp.Canvas.SKMultiLayerRenderCanvas.UpdateWith ( List< SKRenderContext contents,
List< SKRenderAction contentTransforms,
Colour  backgroundColour,
double  width,
double  height 
)

Replace the contents of the SKMultiLayerRenderCanvas with the specified layers.

Parameters
contentsThe contents of the canvas. Each element in this list represents a layer. A Page can be converded to a SKRenderContext through the CopyToSKRenderContext method.
contentTransformsA list of transforms associated with each layer. This list should contain the same number of elements as contents . This is useful to manipulate the position of each layer individually.
backgroundColourThe background colour of the canvas.
widthThe width of the canvas and the page it contains.
heightThe height of the canvas and the page it contains.

Definition at line 166 of file SKMultiLayerRenderCanvas.cs.

Member Data Documentation

◆ LayerTransforms

List<SKRenderAction> VectSharp.Canvas.SKMultiLayerRenderCanvas.LayerTransforms

The list of transforms associated with each layer.

Definition at line 64 of file SKMultiLayerRenderCanvas.cs.

◆ RenderActions

List<List<SKRenderAction> > VectSharp.Canvas.SKMultiLayerRenderCanvas.RenderActions

The list of render actions, each element in this list is itself a list, containing the actions that correspond to a layer in the image.

Definition at line 59 of file SKMultiLayerRenderCanvas.cs.

◆ RenderLock

object VectSharp.Canvas.SKMultiLayerRenderCanvas.RenderLock = new object()

An lock for the rendering loop. The public methods of this class already lock on this, but you may need it if you want to directly manipulate the contents of the canvas.

Definition at line 726 of file SKMultiLayerRenderCanvas.cs.

Property Documentation

◆ PageHeight

double VectSharp.Canvas.SKMultiLayerRenderCanvas.PageHeight
getset

The height of the page that is rendered on this canvas.

Definition at line 53 of file SKMultiLayerRenderCanvas.cs.

◆ PageWidth

double VectSharp.Canvas.SKMultiLayerRenderCanvas.PageWidth
getset

The width of the page that is rendered on this canvas.

Definition at line 48 of file SKMultiLayerRenderCanvas.cs.

◆ Spinner

Func<long, Bitmap> VectSharp.Canvas.SKMultiLayerRenderCanvas.Spinner = null
getset

If the image to draw is not already cached, this method is called with an argument containing the number of milliseconds since the image was last rendered. The method can return a Bitmap that will be drawn on the canvas in order to let users know that the image is being rendered in background.

Definition at line 70 of file SKMultiLayerRenderCanvas.cs.


The documentation for this class was generated from the following file: