Akto.GTLib 1.0.2

dotnet add package Akto.GTLib --version 1.0.2
NuGet\Install-Package Akto.GTLib -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Akto.GTLib" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Akto.GTLib --version 1.0.2
#r "nuget: Akto.GTLib, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Akto.GTLib as a Cake Addin
#addin nuget:?package=Akto.GTLib&version=1.0.2

// Install Akto.GTLib as a Cake Tool
#tool nuget:?package=Akto.GTLib&version=1.0.2

Presentation

GTLib is a small library that allow you to create a pixelated glitch effect on your text on a canvas (in WPF).

To do so, go to the backend file (.cs) of your XAML window. Create an instance of the class GlitchEffect (with no parameters in the constructor). Next set your text like this : YourInstanceOfGlitchEffect.setText("your text","yourFont",30,"TheColorOfYourTextInHexa"); (30 is the fontsize)

The setText function MUST be used before the following functions.

Next you will have to generate the frames, like this : YourInstanceOfGlitchEffect.GenerateFrames(120,8,2); (120 is the number of frames, 20 is the intensity of the effect, 2 is the offset of the pixels affect by the effect)

The GenerateFrames function MUST be used before the following functions.

Finally, we will use the function GetNextFrame to get the frames generated one by one.

If you only want one for a static text with no animation, do this : YourCanvas.Background = YourInstanceOfGlitchEffect.GetNextFrame();

If you want to animate your text with the effect fully, you can do something like this :

    public partial class MainWindow : Window
    {
      GlitchEffect testGlitch;
        public MainWindow()
        {
            InitializeComponent();
            CompositionTarget.Rendering += UpdateLoop;
            testGlitch = new GlitchEffect();
            testGlitch.setText("Hello World","Arial",30, "#1b3646");
            testGlitch.GenerateFrames(120,20,1);
        }
	
        public void UpdateLoop(object sender, EventArgs e)
        {
            testCanvas.Background = testGlitch.GetNextFrame();
        }
    }

Getting the package/lib

https://www.nuget.org/packages/Akto.GTLib#readme-body-tab

live example of the code above :

til

Licence

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 192 3/29/2023
1.0.1 170 3/29/2023
1.0.0 179 3/29/2023