-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from xdanieldzd/restructure
Merging restructure branch
- Loading branch information
Showing
194 changed files
with
7,466 additions
and
3,728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[*.cs] | ||
|
||
# CA1822: Member als statisch markieren | ||
dotnet_diagnostic.CA1822.severity = silent | ||
#dotnet_diagnostic.CA1822.severity = silent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Build | ||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
project: ['StoicGoose', 'StoicGoose.GLWindow'] | ||
include: | ||
- project: StoicGoose | ||
csproj: StoicGoose\StoicGoose.csproj | ||
artifacts: StoicGoose-artifacts | ||
- project: StoicGoose.GLWindow | ||
csproj: StoicGoose.GLWindow\StoicGoose.GLWindow.csproj | ||
artifacts: StoicGoose.GLWindow-artifacts | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: 6.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --no-restore | ||
- name: Publish | ||
run: dotnet publish ${{ matrix.csproj }} -c Release -o release --nologo | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.artifacts }} | ||
path: D:\a\StoicGoose\StoicGoose\release\* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ttributes/ImGuiBitDescriptionAttribute.cs → ...mon/Attributes/BitDescriptionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...erface/Attributes/ImGuiFormatAttribute.cs → ...oose.Common/Attributes/FormatAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...face/Attributes/ImGuiRegisterAttribute.cs → ...cGoose.Common/Attributes/PortAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace StoicGoose | ||
namespace StoicGoose.Common.Console | ||
{ | ||
public static class Ansi | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace StoicGoose.Common.Console | ||
{ | ||
public enum ConsoleLogSeverity { Success, Information, Warning, Error } | ||
|
||
public static class ConsoleHelpers | ||
{ | ||
readonly static Dictionary<ConsoleLogSeverity, string> logSeverityAnsiColors = new() | ||
{ | ||
{ ConsoleLogSeverity.Success, Ansi.Green }, | ||
{ ConsoleLogSeverity.Information, Ansi.Cyan }, | ||
{ ConsoleLogSeverity.Warning, Ansi.Yellow }, | ||
{ ConsoleLogSeverity.Error, Ansi.Red } | ||
}; | ||
|
||
public static void WriteLog(ConsoleLogSeverity severity, object source, string message) | ||
{ | ||
System.Console.WriteLine($"{logSeverityAnsiColors[severity]}[{source.GetType().Name}]{Ansi.Reset}: {message}"); | ||
} | ||
|
||
// Such a stupid gimmick... but hey, I like stupid gimmicks and I especially like making them, so whatever~ | ||
public static void WriteGradientLine(string text, bool useHsl, params (byte r, byte g, byte b)[] colors) | ||
{ | ||
var stepsPerColor = (int)Math.Round(text.Length / (colors.Length - 1f), MidpointRounding.AwayFromZero); | ||
var steps = Math.Max(stepsPerColor * (colors.Length - 1), text.Length); | ||
|
||
List<(byte r, byte g, byte b)> gradient = new(); | ||
|
||
for (int i = 0, c = 0; i < steps; i += stepsPerColor, c++) | ||
{ | ||
if (useHsl) | ||
{ | ||
var (h1, s1, l1) = RgbToHsl(colors[c + 0].r, colors[c + 0].g, colors[c + 0].b); | ||
var (h2, s2, l2) = RgbToHsl(colors[c + 1].r, colors[c + 1].g, colors[c + 1].b); | ||
|
||
for (var j = 0; j < stepsPerColor; j++) | ||
{ | ||
var by = Math.Clamp((j / 1f) / ((stepsPerColor - 1) / 1f), 0f, 1f); | ||
var (h, s, l) = Lerp(h1, s1, l1, h2, s2, l2, by); | ||
gradient.Add(HslToRgb(h, s, l)); | ||
} | ||
} | ||
else | ||
{ | ||
var (r1, g1, b1) = (colors[c + 0].r / 255f, colors[c + 0].g / 255f, colors[c + 0].b / 255f); | ||
var (r2, g2, b2) = (colors[c + 1].r / 255f, colors[c + 1].g / 255f, colors[c + 1].b / 255f); | ||
|
||
for (var j = 0; j < stepsPerColor; j++) | ||
{ | ||
var by = Math.Clamp((j / 1f) / ((stepsPerColor - 1) / 1f), 0f, 1f); | ||
gradient.Add(((byte)(Lerp(r1, r2, by) * 255), (byte)(Lerp(g1, g2, by) * 255), (byte)(Lerp(b1, b2, by) * 255))); | ||
} | ||
} | ||
} | ||
|
||
for (var i = 0; i < Math.Min(gradient.Count, text.Length); i++) | ||
System.Console.Write($"{Ansi.RGB(gradient[i].r, gradient[i].g, gradient[i].b)}{text[i]}"); | ||
System.Console.Write(Environment.NewLine); | ||
} | ||
|
||
private static float Lerp(float v1, float v2, float by) => v1 * (1f - by) + v2 * by; | ||
private static (float h, float s, float l) Lerp(float h1, float s1, float l1, float h2, float s2, float l2, float by) => (Lerp(h1, h2, by) % 360f, Math.Clamp(Lerp(s1, s2, by), 0f, 1f), Math.Clamp(Lerp(l1, l2, by), 0f, 1f)); | ||
|
||
// http://www.easyrgb.com/en/math.php | ||
private static (float h, float s, float l) RgbToHsl(byte red, byte green, byte blue) | ||
{ | ||
float h = 0f, s, l; | ||
|
||
var r = red / 255f; | ||
var g = green / 255f; | ||
var b = blue / 255f; | ||
|
||
var min = Math.Min(Math.Min(r, g), b); | ||
var max = Math.Max(Math.Max(r, g), b); | ||
var deltaMax = max - min; | ||
|
||
l = (max + min) / 2f; | ||
|
||
if (deltaMax == 0) | ||
{ | ||
h = 0; | ||
s = 0; | ||
} | ||
else | ||
{ | ||
if (l < 0.5f) s = deltaMax / (max + min); | ||
else s = deltaMax / (2f - max - min); | ||
|
||
var deltaR = (((max - r) / 6f) + (deltaMax / 2f)) / deltaMax; | ||
var deltaG = (((max - g) / 6f) + (deltaMax / 2f)) / deltaMax; | ||
var deltaB = (((max - b) / 6f) + (deltaMax / 2f)) / deltaMax; | ||
|
||
if (r == max) h = deltaB - deltaG; | ||
else if (g == max) h = (1f / 3f) + deltaR - deltaB; | ||
else if (b == max) h = (2f / 3f) + deltaG - deltaR; | ||
|
||
if (h < 0f) h++; | ||
if (h > 1f) h--; | ||
} | ||
|
||
return (h, s, l); | ||
} | ||
|
||
// http://www.easyrgb.com/en/math.php | ||
private static (byte r, byte g, byte b) HslToRgb(float hue, float saturation, float lightness) | ||
{ | ||
byte r, g, b; | ||
|
||
if (saturation == 0f) | ||
{ | ||
r = (byte)(lightness * 255); | ||
g = (byte)(lightness * 255); | ||
b = (byte)(lightness * 255); | ||
} | ||
else | ||
{ | ||
float v1, v2; | ||
|
||
if (lightness < 0.5f) v2 = lightness * (1f + saturation); | ||
else v2 = (lightness + saturation) - (saturation * lightness); | ||
|
||
v1 = 2f * lightness - v2; | ||
|
||
r = (byte)(255 * HueToRgb(v1, v2, hue + (1f / 3f))); | ||
g = (byte)(255 * HueToRgb(v1, v2, hue)); | ||
b = (byte)(255 * HueToRgb(v1, v2, hue - (1f / 3f))); | ||
} | ||
|
||
return (r, g, b); | ||
} | ||
|
||
private static float HueToRgb(float v1, float v2, float vh) | ||
{ | ||
if (vh < 0f) vh++; | ||
if (vh > 1) vh--; | ||
|
||
if ((6f * vh) < 1f) return v1 + (v2 - v1) * 6f * vh; | ||
if ((2f * vh) < 1f) return v2; | ||
if ((3f * vh) < 2f) return v1 + (v2 - v1) * ((2f / 3f) - vh) * 6f; | ||
return v1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace StoicGoose.Common.Drawing | ||
{ | ||
/* RGBA bitmap file format -- https://github.com/bzotto/rgba_bitmap | ||
* ".rgba is the dumbest possible image interchange format, now available for your programming pleasure." | ||
*/ | ||
|
||
public class RgbaFile | ||
{ | ||
const string expectedMagic = "RGBA"; | ||
|
||
public string MagicNumber { get; protected set; } | ||
public uint Width { get; protected set; } | ||
public uint Height { get; protected set; } | ||
public byte[] PixelData { get; protected set; } | ||
|
||
public RgbaFile(string filename) : this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { } | ||
|
||
public RgbaFile(Stream stream) | ||
{ | ||
MagicNumber = ReadString(stream, 4); | ||
Width = ReadUInt32(stream); | ||
Height = ReadUInt32(stream); | ||
PixelData = new byte[Width * Height * 4]; | ||
stream.Read(PixelData); | ||
} | ||
|
||
public RgbaFile(uint width, uint height, byte[] pixelData) | ||
{ | ||
MagicNumber = expectedMagic; | ||
Width = width; | ||
Height = height; | ||
PixelData = pixelData; | ||
} | ||
|
||
public void Save(string filename) => Save(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)); | ||
|
||
public void Save(Stream stream) | ||
{ | ||
WriteString(stream, MagicNumber); | ||
WriteUInt32(stream, Width); | ||
WriteUInt32(stream, Height); | ||
stream.Write(PixelData); | ||
} | ||
|
||
private static string ReadString(Stream stream, int length) => new(Enumerable.Range(0, length).Select(_ => (char)stream.ReadByte()).ToArray()); | ||
private static uint ReadUInt32(Stream stream) => (uint)(((stream.ReadByte() & 0xFF) << 24) | ((stream.ReadByte() & 0xFF) << 16) | ((stream.ReadByte() & 0xFF) << 8) | ((stream.ReadByte() & 0xFF) << 0)); | ||
|
||
private static void WriteString(Stream stream, string str) => Array.ForEach(str.ToCharArray(), (x) => stream.WriteByte((byte)x)); | ||
private static void WriteUInt32(Stream stream, uint val) { stream.WriteByte((byte)((val >> 24) & 0xFF)); stream.WriteByte((byte)((val >> 16) & 0xFF)); stream.WriteByte((byte)((val >> 8) & 0xFF)); stream.WriteByte((byte)((val >> 0) & 0xFF)); } | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...oose/Extensions/ObjectExtensionMethods.cs → ...mmon/Extensions/ObjectExtensionMethods.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...oose/Extensions/StringExtensionMethods.cs → ...mmon/Extensions/StringExtensionMethods.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../OpenGL/Shaders/Bundles/BundleManifest.cs → .../OpenGL/Shaders/Bundles/BundleManifest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.