VelloSharp.Avalonia.Controls
VelloSharp.Avalonia.Controls
bundles reusable Avalonia UI controls that render directly through the Vello renderer.
It builds on top of VelloSharp.Avalonia.Vello
, exposing a drawing canvas, an animation surface, and an SVG presenter so
you can light up Vello scenes without hand-writing the lease plumbing each time.
Getting Started
- Install with
dotnet add package VelloSharp.Avalonia.Controls
. - Make sure your application registers the Vello backends (
UseWinit()
and/orUseVello()
). - Import the namespace in XAML:
xmlns:controls="clr-namespace:VelloSharp.Avalonia.Controls;assembly=VelloSharp.Avalonia.Controls"
. - Drop the controls into your layouts and handle the provided events/properties.
Key Controls
VelloCanvasControl
– exposes aDraw
event with the liveScene
,RenderParams
, and global transform.VelloAnimatedCanvasControl
– adds a managed render loop withIsPlaying
,FrameRate
,TotalTime
, andDeltaTime
.VelloSvgControl
– rendersVelloSvg
documents from resources, files, or in-memory payloads with familiarStretch
behaviour.
Usage Example
<controls:VelloAnimatedCanvasControl x:Name="AnimatedSurface"
Draw="OnAnimatedDraw"
MinHeight="320"/>
private void OnAnimatedDraw(object? sender, VelloDrawEventArgs e)
{
var scene = e.Scene;
var transform = e.GlobalTransform;
var bounds = e.Bounds;
var rect = new PathBuilder();
rect.MoveTo(bounds.X, bounds.Y);
rect.LineTo(bounds.Right, bounds.Y);
rect.LineTo(bounds.Right, bounds.Bottom);
rect.LineTo(bounds.X, bounds.Bottom);
rect.Close();
scene.FillPath(rect, FillRule.NonZero, transform, new SolidColorBrush(RgbaColor.FromBytes(20, 28, 42)));
}
Sample Application
See samples/AvaloniaVelloControlsSample
in the repository for a complete walkthrough that demonstrates:
- Custom drawing on
VelloCanvasControl
. - Time-based compositions on
VelloAnimatedCanvasControl
. - Resource loading and sizing behaviour in
VelloSvgControl
.
Run it with:
dotnet run --project samples/AvaloniaVelloControlsSample/AvaloniaVelloControlsSample.csproj