This repository has been archived on 2023-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
PainterlyUNO/Matrix App/PregeneratedMods/generators/RandomPixels.cs

32 lines
980 B
C#
Raw Normal View History

2021-06-09 16:43:27 +00:00
using System;
using System.Windows.Forms;
2021-06-11 11:36:55 +00:00
using Matrix_App.PregeneratedMods.reflection;
2021-06-09 16:43:27 +00:00
namespace Matrix_App.PregeneratedMods
{
public class RandomPixels : MatrixGifGenerator
{
2021-06-11 11:36:55 +00:00
[UiWidget]
[UiDescription(title: "Seed", description: "Just a seed for a bad deterministic random function")]
private int seed = 0;
2021-06-09 16:43:27 +00:00
protected override void ColorFragment(in int x, in int y, in float u, in float v, in int frame, out float r, out float g, out float b)
{
2021-06-11 11:36:55 +00:00
r = Next(frame, x, y);
g = Next(frame, x, y + 67);
b = Next(frame, x, y + 34968);
2021-06-09 16:43:27 +00:00
}
protected override void CreateUi(FlowLayoutPanel anchor, update invokeGenerator)
{
}
2021-06-11 11:36:55 +00:00
private float Next(int frame, int x, int y)
2021-06-09 16:43:27 +00:00
{
2021-06-11 11:36:55 +00:00
var k = MathF.Sin(frame * 2356f + (x + y) * 5334f + (y * x) * 534f + 78.0f + seed * 435f) * 567f;
2021-06-09 16:43:27 +00:00
return k - MathF.Floor(k);
}
}
}