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/Spiral.cs

40 lines
1.1 KiB
C#
Raw Normal View History

2021-06-09 16:43:27 +00:00
using System;
using System.Windows.Forms;
2021-06-09 16:43:27 +00:00
namespace Matrix_App.PregeneratedMods
{
public sealed class Spiral : MatrixGifGenerator
{
/**
float spiral(vec2 m) {
float r = length(m);
float a = atan(m.y, m.x);
float v = sin(100.*(sqrt(r)-0.02*a-.3*t));
return clamp(v,0.,1.);
}
*/
2021-06-11 11:36:55 +00:00
private static float SpiralCurve(float s, float t, float time)
2021-06-09 16:43:27 +00:00
{
2021-06-11 11:36:55 +00:00
var r = MathF.Sqrt(s * s + t * t);
var a = MathF.Atan2(t, s);
var v = MathF.Sin(50 * (MathF.Sqrt(r) - 0.02f * a - time));
2021-06-09 16:43:27 +00:00
return v;
}
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
var sp = SpiralCurve((u - 0.5f) * 0.1f, (v - 0.5f) * 0.1f, frame / (float) totalFrames);
2021-06-09 16:43:27 +00:00
r = sp;
g = sp;
b = sp;
}
protected override void CreateUi(FlowLayoutPanel anchor, update invokeGenerator)
{
}
2021-06-09 16:43:27 +00:00
}
}