nor0x.Maui.Kenimation
1.0.2
dotnet add package nor0x.Maui.Kenimation --version 1.0.2
NuGet\Install-Package nor0x.Maui.Kenimation -Version 1.0.2
<PackageReference Include="nor0x.Maui.Kenimation" Version="1.0.2" />
<PackageVersion Include="nor0x.Maui.Kenimation" Version="1.0.2" />
<PackageReference Include="nor0x.Maui.Kenimation" />
paket add nor0x.Maui.Kenimation --version 1.0.2
#r "nuget: nor0x.Maui.Kenimation, 1.0.2"
#addin nuget:?package=nor0x.Maui.Kenimation&version=1.0.2
#tool nuget:?package=nor0x.Maui.Kenimation&version=1.0.2
Kenimation 🖼️→📼
<img src="https://raw.githubusercontent.com/nor0x/Kenimation/main/Art/icon.png" width="300px" />
Kenimation is a customizable SkiaSharp-based view for animating still images. It supports cross-fading, keyframed zoom/pan animations, and several playback modes. Inspired by the Ken Burns effect.
https://github.com/user-attachments/assets/8affa9b9-fdb6-46e9-be1b-5fe2f020e9fe
✨ Features
- 📸 Displays a list of images with Ken Burns effects.
- 🔄 Supports cross-fade transitions between images.
- 🎞️ Keyframed scaling (zoom) and position (motion) with interpolation.
- 🔁 Multiple playback modes (Loop, ReverseAndLoop, PlayOnce, PlayOnceAndStop).
🚀 Basic Usage
1️⃣ Create the view in code or XAML:
xmlns:kb="clr-namespace:Kenimation;assembly=Kenimation"
<ContentPage ...>
<StackLayout>
<kb:KBView x:Name="kenView" />
</StackLayout>
</ContentPage>
2️⃣ Load images:
var images = new List<SKBitmap>
{
SKBitmap.Decode("image1.jpg"),
SKBitmap.Decode("image2.jpg")
};
kenView.LoadImages(images);
3️⃣ Set keyframes (optional):
var keyframes = new List<KBKeyframe>
{
new KBKeyframe { Scale = 1.0f, Position = new SKPoint(0,0), Time = 0 },
new KBKeyframe { Scale = 1.5f, Position = new SKPoint(0.1f,0.1f), Time = 1 }
};
kenView.SetKeyframes(keyframes);
4️⃣ Configure the view (optional):
// Duration of each image’s Ken Burns animation
kenView.AnimationDuration = 5000;
// How two images transition
kenView.TransitionDuration = 1500;
// Control playback mode
kenView.Mode = AnimationMode.ReverseAndLoop;
5️⃣ Start animation:
kenView.StartAnimation();
📚 API Overview
🛠️ Properties
- TransitionDuration: Time (milliseconds) used to cross-fade between images.
- AnimationDuration: Total duration (milliseconds) for a complete Ken Burns cycle on a single image.
- Mode: Defines how the animation progresses (Loop, ReverseAndLoop, PlayOnce, PlayOnceAndStop).
🔧 Methods
- LoadImages(IEnumerable<SKBitmap> images)
Sets multiple images to display in sequence. - SetImage(SKBitmap image)
Sets a single image and replaces the current one. - SetKeyframes(List<KBKeyframe> keyframes)
Configures the zoom/pan animation steps. - StartAnimation()
Begins or resumes the Ken Burns animation and cross-fading. - Pause()
Temporarily stops the Ken Burns animation timer. - Resume()
Continues the animation after a pause. - Dispose()
Cleans up internal resources (bitmaps, timers, etc.).
🎛️ KBKeyframe
Defines a single keyframe with:
- Scale: Zoom factor (1.0 = no zoom).
- Position: Pan offset in normalized coordinates (-1 to 1 recommended).
- Time: When the keyframe is reached (0.0 to 1.0), relative to the overall animation.
🔑 Built-In Keyframes
- DefaultKeyframes
Starts zoomed in at scale=3.0, then moves to scale=1.0 over three seconds. - FourCornersKeyframes
Moves between the four corners of the image while zooming from scale=1.0 to scale=3.0.
You can also generate random keyframes with:
- GetRandomKeyframes(int count)
- GetRandomSmoothKeyframes(int count)
🖥️ CPU Rendering (KBCPURENDERING)
If you want to switch Kenimation from GPU-based rendering (SKGLView
) to CPU-based rendering (SKCanvasView
), simply define KBCPURENDERING
in KBView.cs
.
This setting can be helpful if you encounter device-specific GPU issues or prefer software rendering for debugging or performance evaluations. By toggling this define, you can easily compare rendering fidelity and performance between the two modes.
🖼️ Example
// Simple usage with defaults
var kenView = new KBView();
kenView.LoadImages(new[] { SKBitmap.Decode("image1.jpg"), SKBitmap.Decode("image2.jpg") });
kenView.StartAnimation();
The kenView will automatically animate each image for 5 seconds, then cross-fade to the next using a 1-second transition, with a reversing playback. Adjust the animation parameters, playback mode, or keyframes as needed.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-android35.0 is compatible. net9.0-browser was computed. net9.0-ios was computed. net9.0-ios18.0 is compatible. net9.0-maccatalyst was computed. net9.0-maccatalyst18.0 is compatible. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net9.0-windows10.0.19041 is compatible. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Microsoft.Extensions.Logging.Debug (>= 9.0.4)
- Microsoft.Maui.Controls (>= 9.0.60)
- Microsoft.Maui.Controls.Compatibility (>= 9.0.60)
- SkiaSharp.Views.Maui.Controls (>= 3.116.1)
-
net9.0-android35.0
- Microsoft.Extensions.Logging.Debug (>= 9.0.4)
- Microsoft.Maui.Controls (>= 9.0.60)
- Microsoft.Maui.Controls.Compatibility (>= 9.0.60)
- SkiaSharp.Views.Maui.Controls (>= 3.116.1)
-
net9.0-ios18.0
- Microsoft.Extensions.Logging.Debug (>= 9.0.4)
- Microsoft.Maui.Controls (>= 9.0.60)
- Microsoft.Maui.Controls.Compatibility (>= 9.0.60)
- SkiaSharp.Views.Maui.Controls (>= 3.116.1)
-
net9.0-maccatalyst18.0
- Microsoft.Extensions.Logging.Debug (>= 9.0.4)
- Microsoft.Maui.Controls (>= 9.0.60)
- Microsoft.Maui.Controls.Compatibility (>= 9.0.60)
- SkiaSharp.Views.Maui.Controls (>= 3.116.1)
-
net9.0-windows10.0.19041
- Microsoft.Extensions.Logging.Debug (>= 9.0.4)
- Microsoft.Maui.Controls (>= 9.0.60)
- Microsoft.Maui.Controls.Compatibility (>= 9.0.60)
- SkiaSharp.Views.Maui.Controls (>= 3.116.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.