Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of Inkubator v1.0.4
Inkubator.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using DooDesch.AvatarKit; using DooDesch.UI; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.UI.MainMenu; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Inkubator; using Inkubator.Editor; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using S1API.Rendering; using S1API.UI; using SideHustle; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Core), "Inkubator", "1.0.4", "DooDesch", "https://github.com/DooDesch-Mods/ScheduleOne-Inkubator")] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: MelonOptionalDependencies(new string[] { "SideHustle" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("DooDesch")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © DooDesch")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+5d8727c22e93bcefcf408895cbdbf6a446937d30")] [assembly: AssemblyProduct("Inkubator")] [assembly: AssemblyTitle("Inkubator")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DooDesch.AvatarKit { public static class AvatarLayerSlots { public const int BodySlots = 8; public const int VanillaClearedSlots = 6; public static void LoadAndClean(Avatar avatar, AvatarSettings settings) { if (!((Object)(object)avatar == (Object)null) && !((Object)(object)settings == (Object)null)) { avatar.LoadAvatarSettings(settings); List<LayerSetting> bodyLayerSettings = settings.BodyLayerSettings; int used = ((bodyLayerSettings != null && bodyLayerSettings.Count > 6) ? CountRenderable(bodyLayerSettings) : 6); ClearStaleBodySlots(avatar, used); } } public static int CountRenderable(List<LayerSetting> list) { if (list == null) { return 0; } int num = 0; for (int i = 0; i < list.Count; i++) { if (Renders(list[i].layerPath)) { num++; } } return num; } public static void ClearStaleBodySlots(Avatar avatar, int used) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null || used >= 8) { return; } if (used < 0) { used = 0; } try { Il2CppReferenceArray<SkinnedMeshRenderer> bodyMeshes = avatar.BodyMeshes; for (int i = used + 1; i <= 8; i++) { avatar.SetBodyLayer(i, string.Empty, Color.white); if (bodyMeshes == null) { continue; } for (int j = 0; j < ((Il2CppArrayBase<SkinnedMeshRenderer>)(object)bodyMeshes).Length; j++) { SkinnedMeshRenderer val = ((Il2CppArrayBase<SkinnedMeshRenderer>)(object)bodyMeshes)[j]; if ((Object)(object)val != (Object)null && (Object)(object)((Renderer)val).material != (Object)null) { ((Renderer)val).material.SetTexture("_Layer_" + i + "_Normal", (Texture)null); } } } } catch (Exception) { } } public static List<LayerSetting> TrimToBudget(List<LayerSetting> list, Func<string, int> rank, int max = 8) { List<LayerSetting> list2 = new List<LayerSetting>(); if (list == null || rank == null || list.Count <= max) { return list2; } for (int num = CountRenderable(list) - max; num > 0; num--) { int num2 = -1; int num3 = int.MaxValue; for (int i = 0; i < list.Count; i++) { if (Renders(list[i].layerPath)) { int num4 = rank(list[i].layerPath); if (num4 < num3) { num3 = num4; num2 = i; } } } if (num2 < 0) { break; } list2.Add(list[num2]); list.RemoveAt(num2); } return list2; } public static bool AddOnce(List<LayerSetting> list, string path, Color tint) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (list == null || string.IsNullOrEmpty(path)) { return false; } for (int i = 0; i < list.Count; i++) { if (list[i].layerPath == path) { return false; } } LayerSetting val = new LayerSetting(); val.layerPath = path; val.layerTint = tint; list.Add(val); return true; } private static bool Renders(string layerPath) { if (!string.IsNullOrEmpty(layerPath)) { return Resources.Load(layerPath) != (Object)null; } return false; } } } namespace DooDesch.UI { public static class Theme { public static readonly Color BgDeep = new Color(0.043f, 0.047f, 0.063f, 1f); public static readonly Color BgBase = new Color(0.063f, 0.071f, 0.094f, 1f); public static readonly Color BgPanel = new Color(0.086f, 0.098f, 0.133f, 1f); public static readonly Color BgElevated = new Color(0.114f, 0.129f, 0.173f, 1f); public static readonly Color SurfaceInput = new Color(0.051f, 0.059f, 0.082f, 1f); public static readonly Color Clear = new Color(0f, 0f, 0f, 0f); public static readonly Color Hairline = new Color(1f, 1f, 1f, 0.08f); public static readonly Color HairlineStrong = new Color(1f, 1f, 1f, 0.14f); public static readonly Color ScrimPanel = new Color(0.063f, 0.071f, 0.094f, 0.82f); public static readonly Color ScrimRow = new Color(0.114f, 0.129f, 0.173f, 0.72f); public static readonly Color TextPrimary = new Color(0.925f, 0.929f, 0.945f, 1f); public static readonly Color TextMuted = new Color(0.541f, 0.561f, 0.62f, 1f); public static readonly Color TextDisabled = new Color(0.337f, 0.357f, 0.408f, 1f); public static readonly Color Accent = new Color(0.369f, 0.416f, 0.824f, 1f); public static readonly Color AccentHover = new Color(0.431f, 0.475f, 0.859f, 1f); public static readonly Color AccentPressed = new Color(0.298f, 0.341f, 0.737f, 1f); public static readonly Color AccentSubtle = new Color(0.125f, 0.133f, 0.227f, 1f); public static readonly Color AccentBorder = new Color(0.486f, 0.525f, 0.91f, 1f); public static readonly Color Button = new Color(0.2f, 0.212f, 0.263f, 1f); public static readonly Color Danger = new Color(0.784f, 0.29f, 0.329f, 1f); public static readonly Color DangerText = new Color(0.945f, 0.439f, 0.478f, 1f); public static readonly Color DangerSubtle = new Color(0.165f, 0.082f, 0.094f, 1f); public static readonly Color Warning = new Color(0.788f, 0.569f, 0.18f, 1f); public static readonly Color WarningText = new Color(0.902f, 0.706f, 0.314f, 1f); public static readonly Color WarningSubtle = new Color(0.165f, 0.133f, 0.071f, 1f); public static readonly Color Success = new Color(0.184f, 0.659f, 0.467f, 1f); public static readonly Color SuccessText = new Color(0.373f, 0.816f, 0.604f, 1f); public static readonly Color SuccessSubtle = new Color(0.071f, 0.165f, 0.125f, 1f); public static readonly Color Info = new Color(0.239f, 0.498f, 0.753f, 1f); public static readonly Color InfoText = new Color(0.435f, 0.659f, 0.902f, 1f); public static readonly Color InfoSubtle = new Color(0.071f, 0.125f, 0.192f, 1f); public const int RadiusMd = 6; public const float Fade = 0.12f; public const int Caption = 11; public const int Body = 13; public const int Label = 14; public const int H3 = 16; public const int H2 = 20; public const int H1 = 28; private static Sprite _rounded; private static Sprite _frame; public static Color Lighten(Color c, float amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Clamp01(c.r + amount), Mathf.Clamp01(c.g + amount), Mathf.Clamp01(c.b + amount), c.a); } public static Color Darken(Color c, float amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Lighten(c, 0f - amount); } public static Color WithAlpha(Color c, float a) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, a); } public static Sprite RoundedSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rounded != (Object)null) { return _rounded; } Texture2D val = new Texture2D(32, 32, (TextureFormat)5, false); ((Object)val).hideFlags = (HideFlags)32; Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { bool flag = ((float)j < 6f && (float)i < 6f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(6f, 6f)) > 6f) || ((float)j > 25f && (float)i < 6f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(25f, 6f)) > 6f) || ((float)j < 6f && (float)i > 25f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(6f, 25f)) > 6f) || ((float)j > 25f && (float)i > 25f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(25f, 25f)) > 6f); val.SetPixel(j, i, Color32.op_Implicit(flag ? val2 : val3)); } } val.Apply(); _rounded = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(8f, 8f, 8f, 8f)); return _rounded; } public static Sprite FrameSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_frame != (Object)null) { return _frame; } Texture2D val = new Texture2D(32, 32, (TextureFormat)5, false); ((Object)val).hideFlags = (HideFlags)32; Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { bool flag = j < 3 || j >= 29 || i < 3 || i >= 29; val.SetPixel(j, i, Color32.op_Implicit(flag ? val3 : val2)); } } val.Apply(); _frame = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(4f, 4f, 4f, 4f)); return _frame; } } public static class Interactions { public static void PolishButtons(Transform root, bool round = true) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Il2CppArrayBase<Button> componentsInChildren = ((Component)root).GetComponentsInChildren<Button>(true); if (componentsInChildren == null) { return; } for (int i = 0; i < componentsInChildren.Length; i++) { Button val = componentsInChildren[i]; if ((Object)(object)val == (Object)null) { continue; } Graphic targetGraphic = ((Selectable)val).targetGraphic; Image val2 = (Image)(((object)((targetGraphic is Image) ? targetGraphic : null)) ?? ((object)((Component)val).GetComponent<Image>())); if (!((Object)(object)val2 == (Object)null) && !(((Graphic)val2).color.a < 0.02f)) { if (round) { val2.sprite = Theme.RoundedSprite(); val2.type = (Type)1; } ApplyStates(val); } } } public static void ApplyStates(Button btn) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) Graphic targetGraphic = ((Selectable)btn).targetGraphic; Image val = (Image)(((object)((targetGraphic is Image) ? targetGraphic : null)) ?? ((object)((Component)btn).GetComponent<Image>())); if (!((Object)(object)val == (Object)null)) { Color color = ((Graphic)val).color; if (!(color.a < 0.02f)) { Color val2 = Theme.Lighten(color, 0.06f); Color target = Theme.Darken(color, 0.06f); Color target2 = Color.Lerp(color, Theme.BgPanel, 0.55f); target2.a = color.a * 0.6f; ((Graphic)val).color = val2; ColorBlock colors = ((Selectable)btn).colors; ((ColorBlock)(ref colors)).normalColor = Ratio(color, val2); ((ColorBlock)(ref colors)).highlightedColor = Color.white; ((ColorBlock)(ref colors)).pressedColor = Ratio(target, val2); ((ColorBlock)(ref colors)).selectedColor = Ratio(color, val2); ((ColorBlock)(ref colors)).disabledColor = Ratio(target2, val2); ((ColorBlock)(ref colors)).colorMultiplier = 1f; ((ColorBlock)(ref colors)).fadeDuration = 0.12f; ((Selectable)btn).colors = colors; ((Selectable)btn).transition = (Transition)1; } } } private static Color Ratio(Color target, Color baseC) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) return new Color((baseC.r <= 0.0001f) ? 0f : Mathf.Clamp01(target.r / baseC.r), (baseC.g <= 0.0001f) ? 0f : Mathf.Clamp01(target.g / baseC.g), (baseC.b <= 0.0001f) ? 0f : Mathf.Clamp01(target.b / baseC.b), (baseC.a <= 0.0001f) ? 0f : Mathf.Clamp01(target.a / baseC.a)); } } public enum Severity { Info, Success, Warning, Danger } public static class Components { public static void SeverityColors(Severity s, out Color bar, out Color text, out Color bg) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) switch (s) { case Severity.Success: bar = Theme.Success; text = Theme.SuccessText; bg = Theme.SuccessSubtle; break; case Severity.Warning: bar = Theme.Warning; text = Theme.WarningText; bg = Theme.WarningSubtle; break; case Severity.Danger: bar = Theme.Danger; text = Theme.DangerText; bg = Theme.DangerSubtle; break; default: bar = Theme.Info; text = Theme.InfoText; bg = Theme.InfoSubtle; break; } } public static GameObject Divider(Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) GameObject obj = UIFactory.Panel("Divider", parent, Theme.Hairline, (Vector2?)null, (Vector2?)null, false); Image component = obj.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { ((Graphic)component).raycastTarget = false; } return obj; } public static float Banner(Transform parent, Severity sev, string text, float y, float height = 30f, float gap = 6f, float inset = 16f) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) SeverityColors(sev, out var bar, out var text2, out var bg); GameObject val = UIFactory.Panel("banner", parent, bg, (Vector2?)null, (Vector2?)null, false); Image component = val.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = Theme.RoundedSprite(); component.type = (Type)1; ((Graphic)component).raycastTarget = false; } RectTransform component2 = val.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(0.5f, 1f); component2.offsetMin = new Vector2(inset, y - height); component2.offsetMax = new Vector2(0f - inset, y); GameObject obj = UIFactory.Panel("bar", val.transform, bar, (Vector2?)null, (Vector2?)null, false); Image component3 = obj.GetComponent<Image>(); if ((Object)(object)component3 != (Object)null) { ((Graphic)component3).raycastTarget = false; } RectTransform component4 = obj.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 0f); component4.anchorMax = new Vector2(0f, 1f); component4.pivot = new Vector2(0f, 0.5f); component4.offsetMin = new Vector2(0f, 4f); component4.offsetMax = new Vector2(3f, -4f); Text obj2 = UIFactory.Text("t", text, val.transform, 13, (TextAnchor)3, (FontStyle)0); ((Graphic)obj2).color = text2; ((Graphic)obj2).raycastTarget = false; obj2.horizontalOverflow = (HorizontalWrapMode)0; obj2.verticalOverflow = (VerticalWrapMode)0; RectTransform rectTransform = ((Graphic)obj2).rectTransform; rectTransform.anchorMin = new Vector2(0f, 0f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.offsetMin = new Vector2(12f, 0f); rectTransform.offsetMax = new Vector2(-8f, 0f); return y - (height + gap); } public static GameObject Segmented(Transform parent, string[] labels, int active, Action<int> onSelect, out Button[] buttons, bool vertical = false, float spacing = 6f, Texture2D[] icons = null) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("segmented"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>(); if (vertical) { VerticalLayoutGroup obj = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = spacing; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = true; } else { HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = spacing; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = true; } Button[] btns = (Button[])(object)new Button[labels.Length]; for (int i = 0; i < labels.Length; i++) { int idx = i; Texture2D val2 = ((icons != null && i < icons.Length) ? icons[i] : null); ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.ButtonWithLabel("seg_" + i, ((Object)(object)val2 != (Object)null) ? "" : labels[i], val.transform, (i == active) ? Theme.Accent : Theme.Button, 0f, 0f); GameObject item = valueTuple.Item1; Button item2 = valueTuple.Item2; Text item3 = valueTuple.Item3; LayoutElement obj3 = item.AddComponent<LayoutElement>(); obj3.flexibleWidth = 1f; obj3.flexibleHeight = 1f; obj3.minHeight = 28f; if ((Object)(object)item3 != (Object)null) { item3.fontSize = 14; } if ((Object)(object)val2 != (Object)null) { AddCenterIcon(item.transform, val2, 20f); } ((UnityEvent)item2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { SetSegmentedActive(btns, idx); onSelect?.Invoke(idx); })); btns[i] = item2; } buttons = btns; return val; } public static void AddCenterIcon(Transform parent, Texture2D tex, float size) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)tex == (Object)null)) { GameObject val = new GameObject("icon"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0.5f, 0.5f); obj.anchorMax = new Vector2(0.5f, 0.5f); obj.pivot = new Vector2(0.5f, 0.5f); obj.sizeDelta = new Vector2(size, size); obj.anchoredPosition = Vector2.zero; Image obj2 = val.AddComponent<Image>(); obj2.sprite = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f), 100f); obj2.preserveAspect = true; ((Graphic)obj2).raycastTarget = false; } } public static void ConfirmDialog(Transform canvasRoot, string title, string message, string confirmLabel, Action onConfirm) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) GameObject scrim; if (!((Object)(object)canvasRoot == (Object)null)) { scrim = UIFactory.Panel("DD_ConfirmScrim", canvasRoot, new Color(0f, 0f, 0f, 0.6f), (Vector2?)null, (Vector2?)null, true); scrim.transform.SetAsLastSibling(); GameObject val = UIFactory.Panel("catcher", scrim.transform, new Color(0f, 0f, 0f, 0.01f), (Vector2?)null, (Vector2?)null, true); Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val.GetComponent<Image>(); ((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Close(); })); GameObject val2 = UIFactory.Panel("card", scrim.transform, Theme.BgElevated, (Vector2?)null, (Vector2?)null, false); Image component = val2.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = Theme.RoundedSprite(); component.type = (Type)1; } RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.pivot = new Vector2(0.5f, 0.5f); component2.sizeDelta = new Vector2(440f, 190f); Outline obj2 = val2.AddComponent<Outline>(); ((Shadow)obj2).effectColor = Theme.HairlineStrong; ((Shadow)obj2).effectDistance = new Vector2(1f, -1f); Text obj3 = UIFactory.Text("title", title, val2.transform, 16, (TextAnchor)0, (FontStyle)1); ((Graphic)obj3).color = Theme.TextPrimary; ((Graphic)obj3).raycastTarget = false; RectTransform rectTransform = ((Graphic)obj3).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.offsetMin = new Vector2(20f, -52f); rectTransform.offsetMax = new Vector2(-20f, -18f); Text obj4 = UIFactory.Text("msg", message, val2.transform, 13, (TextAnchor)0, (FontStyle)0); ((Graphic)obj4).color = Theme.TextMuted; ((Graphic)obj4).raycastTarget = false; RectTransform rectTransform2 = ((Graphic)obj4).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 1f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0.5f, 1f); rectTransform2.offsetMin = new Vector2(20f, -120f); rectTransform2.offsetMax = new Vector2(-20f, -58f); ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.ButtonWithLabel("Cancel", "Cancel", val2.transform, Theme.Button, 140f, 40f); GameObject item = valueTuple.Item1; Button item2 = valueTuple.Item2; RectTransform component3 = item.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 0f); component3.anchorMax = new Vector2(0f, 0f); component3.pivot = new Vector2(0f, 0f); component3.anchoredPosition = new Vector2(20f, 18f); component3.sizeDelta = new Vector2(140f, 40f); ((UnityEvent)item2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Close(); })); ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.ButtonWithLabel("Confirm", confirmLabel, val2.transform, Theme.Danger, 180f, 40f); GameObject item3 = valueTuple2.Item1; Button item4 = valueTuple2.Item2; RectTransform component4 = item3.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(1f, 0f); component4.anchorMax = new Vector2(1f, 0f); component4.pivot = new Vector2(1f, 0f); component4.anchoredPosition = new Vector2(-20f, 18f); component4.sizeDelta = new Vector2(180f, 40f); ((UnityEvent)item4.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Close(); onConfirm?.Invoke(); })); Interactions.PolishButtons(val2.transform); } void Close() { Object.Destroy((Object)(object)scrim); } } public static void ChoiceDialog(Transform canvasRoot, string title, string message, IReadOnlyList<string> items, params (string Label, Color Color, Action OnClick)[] choices) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_062f: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0690: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)canvasRoot == (Object)null) { return; } GameObject scrim = UIFactory.Panel("DD_ChoiceScrim", canvasRoot, new Color(0f, 0f, 0f, 0.6f), (Vector2?)null, (Vector2?)null, true); scrim.transform.SetAsLastSibling(); GameObject val = UIFactory.Panel("catcher", scrim.transform, new Color(0f, 0f, 0f, 0.01f), (Vector2?)null, (Vector2?)null, true); Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val.GetComponent<Image>(); ((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Close(); })); int num = items?.Count ?? 0; float num2 = ((num > 0) ? ((float)Mathf.Min(num, 7) * 24f + 12f) : 0f); int num3 = ((choices != null) ? choices.Length : 0) + 1; float num4 = 108f + ((num2 > 0f) ? (num2 + 10f) : 0f); float num5 = num4 + (float)num3 * 46f + 12f; GameObject val2 = UIFactory.Panel("card", scrim.transform, Theme.BgElevated, (Vector2?)null, (Vector2?)null, false); Image component = val2.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = Theme.RoundedSprite(); component.type = (Type)1; } RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.pivot = new Vector2(0.5f, 0.5f); component2.sizeDelta = new Vector2(480f, num5); Outline obj2 = val2.AddComponent<Outline>(); ((Shadow)obj2).effectColor = Theme.HairlineStrong; ((Shadow)obj2).effectDistance = new Vector2(1f, -1f); Text obj3 = UIFactory.Text("title", title, val2.transform, 16, (TextAnchor)0, (FontStyle)1); ((Graphic)obj3).color = Theme.TextPrimary; ((Graphic)obj3).raycastTarget = false; RectTransform rectTransform = ((Graphic)obj3).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.offsetMin = new Vector2(20f, -52f); rectTransform.offsetMax = new Vector2(-20f, -18f); Text obj4 = UIFactory.Text("msg", message, val2.transform, 13, (TextAnchor)0, (FontStyle)0); ((Graphic)obj4).color = Theme.TextMuted; ((Graphic)obj4).raycastTarget = false; RectTransform rectTransform2 = ((Graphic)obj4).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 1f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0.5f, 1f); rectTransform2.offsetMin = new Vector2(20f, -100f); rectTransform2.offsetMax = new Vector2(-20f, -56f); if (num2 > 0f) { GameObject obj5 = UIFactory.Panel("items", val2.transform, Theme.SurfaceInput, (Vector2?)null, (Vector2?)null, false); Image component3 = obj5.GetComponent<Image>(); if ((Object)(object)component3 != (Object)null) { component3.sprite = Theme.RoundedSprite(); component3.type = (Type)1; } RectTransform component4 = obj5.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 1f); component4.anchorMax = new Vector2(1f, 1f); component4.pivot = new Vector2(0.5f, 1f); component4.offsetMin = new Vector2(20f, 0f - (108f + num2)); component4.offsetMax = new Vector2(-20f, -108f); ScrollRect scroll; RectTransform val3 = ScrollList(obj5.transform, out scroll, 0f); for (int num6 = 0; num6 < num; num6++) { GameObject val4 = UIFactory.Panel("item", (Transform)(object)val3, Theme.Clear, (Vector2?)null, (Vector2?)null, false); LayoutElement obj6 = val4.AddComponent<LayoutElement>(); obj6.minHeight = 24f; obj6.preferredHeight = 24f; obj6.flexibleWidth = 1f; Text obj7 = UIFactory.Text("text", items[num6], val4.transform, 13, (TextAnchor)3, (FontStyle)0); ((Graphic)obj7).color = Theme.TextPrimary; ((Graphic)obj7).raycastTarget = false; RectTransform rectTransform3 = ((Graphic)obj7).rectTransform; rectTransform3.anchorMin = Vector2.zero; rectTransform3.anchorMax = Vector2.one; rectTransform3.offsetMin = new Vector2(10f, 0f); rectTransform3.offsetMax = new Vector2(-10f, 0f); } } float num7 = num4; if (choices != null) { foreach ((string, Color, Action) tuple in choices) { (string Label, Color Color, Action OnClick) c = tuple; ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.ButtonWithLabel(c.Label, c.Label, val2.transform, c.Color, 440f, 40f); GameObject item = valueTuple.Item1; Button item2 = valueTuple.Item2; RectTransform component5 = item.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(0f, 1f); component5.anchorMax = new Vector2(1f, 1f); component5.pivot = new Vector2(0.5f, 1f); component5.offsetMin = new Vector2(20f, 0f - (num7 + 40f)); component5.offsetMax = new Vector2(-20f, 0f - num7); ((UnityEvent)item2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Close(); c.OnClick?.Invoke(); })); num7 += 46f; } } ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.ButtonWithLabel("Cancel", "Cancel", val2.transform, Theme.Button, 440f, 40f); GameObject item3 = valueTuple2.Item1; Button item4 = valueTuple2.Item2; RectTransform component6 = item3.GetComponent<RectTransform>(); component6.anchorMin = new Vector2(0f, 1f); component6.anchorMax = new Vector2(1f, 1f); component6.pivot = new Vector2(0.5f, 1f); component6.offsetMin = new Vector2(20f, 0f - (num7 + 40f)); component6.offsetMax = new Vector2(-20f, 0f - num7); ((UnityEvent)item4.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Close(); })); Interactions.PolishButtons(val2.transform); void Close() { Object.Destroy((Object)(object)scrim); } } public static GameObject ProgressBar(Transform parent, out Image fill, float height = 8f) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("DD_Progress", parent, Theme.AccentSubtle, (Vector2?)null, (Vector2?)null, false); Image component = val.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = Theme.RoundedSprite(); component.type = (Type)1; } RectTransform component2 = val.GetComponent<RectTransform>(); component2.sizeDelta = new Vector2(component2.sizeDelta.x, height); GameObject val2 = UIFactory.Panel("fill", val.transform, Theme.Accent, (Vector2?)null, (Vector2?)null, false); fill = val2.GetComponent<Image>(); if ((Object)(object)fill != (Object)null) { fill.sprite = Theme.RoundedSprite(); fill.type = (Type)1; } RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = new Vector2(0f, 1f); component3.offsetMin = Vector2.zero; component3.offsetMax = Vector2.zero; return val; } public static void SetProgressBar(Image fill, float fraction01) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)fill == (Object)null)) { ((Graphic)fill).rectTransform.anchorMax = new Vector2(Mathf.Clamp01(fraction01), 1f); } } public static GameObject CountdownDialog(Transform canvasRoot, string title, string message, string confirmLabel, string cancelLabel, Action onConfirm, Action onCancel, out Text countdownLabel, Action onDismiss = null) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) countdownLabel = null; if ((Object)(object)canvasRoot == (Object)null) { return null; } GameObject val = UIFactory.Panel("DD_CountdownScrim", canvasRoot, new Color(0f, 0f, 0f, 0.6f), (Vector2?)null, (Vector2?)null, true); val.transform.SetAsLastSibling(); if (onDismiss != null) { GameObject val2 = UIFactory.Panel("catcher", val.transform, new Color(0f, 0f, 0f, 0.01f), (Vector2?)null, (Vector2?)null, true); Button obj = val2.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val2.GetComponent<Image>(); ((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { try { onDismiss(); } catch { } })); } GameObject val3 = UIFactory.Panel("card", val.transform, Theme.BgElevated, (Vector2?)null, (Vector2?)null, false); Image component = val3.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = Theme.RoundedSprite(); component.type = (Type)1; } RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.pivot = new Vector2(0.5f, 0.5f); component2.sizeDelta = new Vector2(460f, 220f); Outline obj2 = val3.AddComponent<Outline>(); ((Shadow)obj2).effectColor = Theme.HairlineStrong; ((Shadow)obj2).effectDistance = new Vector2(1f, -1f); Text obj3 = UIFactory.Text("title", title, val3.transform, 16, (TextAnchor)0, (FontStyle)1); ((Graphic)obj3).color = Theme.TextPrimary; ((Graphic)obj3).raycastTarget = false; RectTransform rectTransform = ((Graphic)obj3).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.offsetMin = new Vector2(20f, -52f); rectTransform.offsetMax = new Vector2(-20f, -18f); Text obj4 = UIFactory.Text("msg", message, val3.transform, 13, (TextAnchor)0, (FontStyle)0); ((Graphic)obj4).color = Theme.TextMuted; ((Graphic)obj4).raycastTarget = false; RectTransform rectTransform2 = ((Graphic)obj4).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 1f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0.5f, 1f); rectTransform2.offsetMin = new Vector2(20f, -116f); rectTransform2.offsetMax = new Vector2(-20f, -56f); Text val4 = UIFactory.Text("countdown", "", val3.transform, 13, (TextAnchor)0, (FontStyle)1); ((Graphic)val4).color = Theme.TextPrimary; ((Graphic)val4).raycastTarget = false; RectTransform rectTransform3 = ((Graphic)val4).rectTransform; rectTransform3.anchorMin = new Vector2(0f, 1f); rectTransform3.anchorMax = new Vector2(1f, 1f); rectTransform3.pivot = new Vector2(0.5f, 1f); rectTransform3.offsetMin = new Vector2(20f, -148f); rectTransform3.offsetMax = new Vector2(-20f, -118f); countdownLabel = val4; ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.ButtonWithLabel("Cancel", cancelLabel, val3.transform, Theme.Button, 140f, 40f); GameObject item = valueTuple.Item1; Button item2 = valueTuple.Item2; RectTransform component3 = item.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 0f); component3.anchorMax = new Vector2(0f, 0f); component3.pivot = new Vector2(0f, 0f); component3.anchoredPosition = new Vector2(20f, 18f); component3.sizeDelta = new Vector2(140f, 40f); ((UnityEvent)item2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { try { onCancel?.Invoke(); } catch { } })); ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.ButtonWithLabel("Confirm", confirmLabel, val3.transform, Theme.Accent, 180f, 40f); GameObject item3 = valueTuple2.Item1; Button item4 = valueTuple2.Item2; RectTransform component4 = item3.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(1f, 0f); component4.anchorMax = new Vector2(1f, 0f); component4.pivot = new Vector2(1f, 0f); component4.anchoredPosition = new Vector2(-20f, 18f); component4.sizeDelta = new Vector2(180f, 40f); ((UnityEvent)item4.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { try { onConfirm?.Invoke(); } catch { } })); if (onDismiss != null) { var (val5, val6, val7) = UIFactory.ButtonWithLabel("Dismiss", "X", val3.transform, Theme.Button, 30f, 30f); if ((Object)(object)val7 != (Object)null) { val7.fontSize = 18; } RectTransform component5 = val5.GetComponent<RectTransform>(); Vector2 val8 = default(Vector2); ((Vector2)(ref val8))..ctor(1f, 1f); component5.anchorMax = val8; component5.anchorMin = val8; component5.pivot = new Vector2(1f, 1f); component5.anchoredPosition = new Vector2(-10f, -10f); component5.sizeDelta = new Vector2(30f, 30f); ((UnityEvent)val6.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { try { onDismiss(); } catch { } })); rectTransform.offsetMax = new Vector2(-44f, -18f); } Interactions.PolishButtons(val3.transform); return val; } public static void PromptDialog(Transform canvasRoot, string title, string message, string placeholder, string confirmLabel, Func<string, string> onConfirm) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) GameObject scrim; InputField input; Text err; if (!((Object)(object)canvasRoot == (Object)null)) { scrim = UIFactory.Panel("DD_PromptScrim", canvasRoot, new Color(0f, 0f, 0f, 0.6f), (Vector2?)null, (Vector2?)null, true); scrim.transform.SetAsLastSibling(); GameObject val = UIFactory.Panel("catcher", scrim.transform, new Color(0f, 0f, 0f, 0.01f), (Vector2?)null, (Vector2?)null, true); Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val.GetComponent<Image>(); ((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Close(); })); GameObject val2 = UIFactory.Panel("card", scrim.transform, Theme.BgElevated, (Vector2?)null, (Vector2?)null, false); Image component = val2.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = Theme.RoundedSprite(); component.type = (Type)1; } RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.pivot = new Vector2(0.5f, 0.5f); component2.sizeDelta = new Vector2(460f, 250f); Outline obj2 = val2.AddComponent<Outline>(); ((Shadow)obj2).effectColor = Theme.HairlineStrong; ((Shadow)obj2).effectDistance = new Vector2(1f, -1f); Text obj3 = UIFactory.Text("title", title, val2.transform, 16, (TextAnchor)0, (FontStyle)1); ((Graphic)obj3).color = Theme.TextPrimary; ((Graphic)obj3).raycastTarget = false; RectTransform rectTransform = ((Graphic)obj3).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.offsetMin = new Vector2(20f, -52f); rectTransform.offsetMax = new Vector2(-20f, -18f); Text obj4 = UIFactory.Text("msg", message, val2.transform, 13, (TextAnchor)0, (FontStyle)0); ((Graphic)obj4).color = Theme.TextMuted; ((Graphic)obj4).raycastTarget = false; obj4.horizontalOverflow = (HorizontalWrapMode)0; obj4.verticalOverflow = (VerticalWrapMode)0; RectTransform rectTransform2 = ((Graphic)obj4).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 1f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0.5f, 1f); rectTransform2.offsetMin = new Vector2(20f, -98f); rectTransform2.offsetMax = new Vector2(-20f, -58f); input = TextInput(val2.transform, "", null, placeholder, 64); RectTransform component3 = ((Component)input).GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(1f, 1f); component3.pivot = new Vector2(0.5f, 1f); component3.offsetMin = new Vector2(20f, -150f); component3.offsetMax = new Vector2(-20f, -110f); err = UIFactory.Text("err", "", val2.transform, 11, (TextAnchor)0, (FontStyle)0); ((Graphic)err).color = Theme.DangerText; ((Graphic)err).raycastTarget = false; RectTransform rectTransform3 = ((Graphic)err).rectTransform; rectTransform3.anchorMin = new Vector2(0f, 1f); rectTransform3.anchorMax = new Vector2(1f, 1f); rectTransform3.pivot = new Vector2(0.5f, 1f); rectTransform3.offsetMin = new Vector2(20f, -178f); rectTransform3.offsetMax = new Vector2(-20f, -152f); ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.ButtonWithLabel("Cancel", "Cancel", val2.transform, Theme.Button, 140f, 40f); GameObject item = valueTuple.Item1; Button item2 = valueTuple.Item2; RectTransform component4 = item.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 0f); component4.anchorMax = new Vector2(0f, 0f); component4.pivot = new Vector2(0f, 0f); component4.anchoredPosition = new Vector2(20f, 18f); component4.sizeDelta = new Vector2(140f, 40f); ((UnityEvent)item2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Close(); })); ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.ButtonWithLabel("Confirm", confirmLabel, val2.transform, Theme.Accent, 180f, 40f); GameObject item3 = valueTuple2.Item1; Button item4 = valueTuple2.Item2; RectTransform component5 = item3.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(1f, 0f); component5.anchorMax = new Vector2(1f, 0f); component5.pivot = new Vector2(1f, 0f); component5.anchoredPosition = new Vector2(-20f, 18f); component5.sizeDelta = new Vector2(180f, 40f); ((UnityEvent)item4.onClick).AddListener(UnityAction.op_Implicit((Action)delegate { Submit(); })); Interactions.PolishButtons(val2.transform); } void Close() { Object.Destroy((Object)(object)scrim); } void Submit() { string text = ((onConfirm != null) ? onConfirm(input.text) : null); if (string.IsNullOrEmpty(text)) { Close(); } else { err.text = text; } } } public static void SetSegmentedActive(Button[] buttons, int active) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (buttons == null) { return; } for (int i = 0; i < buttons.Length; i++) { if (!((Object)(object)buttons[i] == (Object)null)) { Graphic targetGraphic = ((Selectable)buttons[i]).targetGraphic; Image val = (Image)(((object)((targetGraphic is Image) ? targetGraphic : null)) ?? ((object)((Component)buttons[i]).GetComponent<Image>())); if (!((Object)(object)val == (Object)null)) { ((Graphic)val).color = ((i == active) ? Theme.Accent : Theme.Button); Interactions.ApplyStates(buttons[i]); } } } } public static Slider Slider(Transform parent, float min, float max, float value, Action<float> onChange, float step = 0f) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("slider"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>(); Slider slider = val.AddComponent<Slider>(); GameObject val2 = new GameObject("Background"); val2.transform.SetParent(val.transform, false); RectTransform obj = val2.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 0.5f); obj.anchorMax = new Vector2(1f, 0.5f); obj.sizeDelta = new Vector2(0f, 6f); obj.anchoredPosition = Vector2.zero; Image obj2 = val2.AddComponent<Image>(); ((Graphic)obj2).color = Theme.AccentSubtle; obj2.sprite = Theme.RoundedSprite(); obj2.type = (Type)1; GameObject val3 = new GameObject("Fill Area"); val3.transform.SetParent(val.transform, false); RectTransform obj3 = val3.AddComponent<RectTransform>(); obj3.anchorMin = new Vector2(0f, 0.5f); obj3.anchorMax = new Vector2(1f, 0.5f); obj3.sizeDelta = new Vector2(-16f, 6f); obj3.anchoredPosition = Vector2.zero; GameObject val4 = new GameObject("Fill"); val4.transform.SetParent(val3.transform, false); RectTransform val5 = val4.AddComponent<RectTransform>(); val5.anchorMin = new Vector2(0f, 0f); val5.anchorMax = new Vector2(1f, 1f); val5.sizeDelta = Vector2.zero; Image obj4 = val4.AddComponent<Image>(); ((Graphic)obj4).color = Theme.Accent; obj4.sprite = Theme.RoundedSprite(); obj4.type = (Type)1; GameObject val6 = new GameObject("Handle Slide Area"); val6.transform.SetParent(val.transform, false); RectTransform obj5 = val6.AddComponent<RectTransform>(); obj5.anchorMin = new Vector2(0f, 0f); obj5.anchorMax = new Vector2(1f, 1f); obj5.sizeDelta = new Vector2(-16f, 0f); obj5.anchoredPosition = Vector2.zero; GameObject val7 = new GameObject("Handle"); val7.transform.SetParent(val6.transform, false); RectTransform val8 = val7.AddComponent<RectTransform>(); val8.sizeDelta = new Vector2(16f, 16f); Image val9 = val7.AddComponent<Image>(); ((Graphic)val9).color = Theme.AccentBorder; val9.sprite = Theme.RoundedSprite(); val9.type = (Type)1; slider.fillRect = val5; slider.handleRect = val8; ((Selectable)slider).targetGraphic = (Graphic)(object)val9; slider.direction = (Direction)0; slider.minValue = min; slider.maxValue = max; slider.wholeNumbers = false; Func<float, float> snap = (float v) => (!(step > 0f)) ? v : Mathf.Clamp(Mathf.Round((v - min) / step) * step + min, min, max); slider.value = snap(value); bool reentry = false; ((UnityEvent<float>)(object)slider.onValueChanged).AddListener(UnityAction<float>.op_Implicit((Action<float>)delegate(float v) { if (!reentry) { float num = snap(v); if (step > 0f && !Mathf.Approximately(num, v)) { reentry = true; slider.value = num; reentry = false; } onChange?.Invoke(num); } })); return slider; } public static Toggle Toggle(Transform parent, bool value, Action<bool> onChange) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) float onX = 11f; float offX = 0f - onX; GameObject val = new GameObject("toggle"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>().sizeDelta = new Vector2(46f, 24f); Image track = val.AddComponent<Image>(); track.sprite = Theme.RoundedSprite(); track.type = (Type)1; GameObject val2 = new GameObject("knob"); val2.transform.SetParent(val.transform, false); RectTransform krt = val2.AddComponent<RectTransform>(); RectTransform obj = krt; RectTransform obj2 = krt; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); obj2.anchorMax = val3; obj.anchorMin = val3; krt.pivot = new Vector2(0.5f, 0.5f); krt.sizeDelta = new Vector2(18f, 18f); Image obj3 = val2.AddComponent<Image>(); obj3.sprite = Theme.RoundedSprite(); obj3.type = (Type)1; ((Graphic)obj3).color = Theme.TextPrimary; ((Graphic)obj3).raycastTarget = false; Toggle obj4 = val.AddComponent<Toggle>(); ((Selectable)obj4).transition = (Transition)0; ((Selectable)obj4).targetGraphic = (Graphic)(object)track; obj4.graphic = null; obj4.isOn = value; Render(value); ((UnityEvent<bool>)(object)obj4.onValueChanged).AddListener(UnityAction<bool>.op_Implicit((Action<bool>)delegate(bool on) { Render(on); onChange?.Invoke(on); })); return obj4; void Render(bool on) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) ((Graphic)track).color = (on ? Theme.Accent : Theme.SurfaceInput); krt.anchoredPosition = new Vector2(on ? onX : offX, 0f); } } public static InputField TextInput(Transform parent, string value, Action<string> onChange, string placeholder = null, int characterLimit = 0, bool numeric = false) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("input"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>(); Image obj = val.AddComponent<Image>(); ((Graphic)obj).color = Theme.SurfaceInput; obj.sprite = Theme.RoundedSprite(); obj.type = (Type)1; val.AddComponent<RectMask2D>(); InputField val2 = val.AddComponent<InputField>(); GameObject val3 = new GameObject("Text"); val3.transform.SetParent(val.transform, false); RectTransform obj2 = val3.AddComponent<RectTransform>(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = new Vector2(8f, 2f); obj2.offsetMax = new Vector2(-6f, -2f); Text val4 = val3.AddComponent<Text>(); val4.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); val4.fontSize = 14; ((Graphic)val4).color = Theme.TextPrimary; val4.alignment = (TextAnchor)3; val4.supportRichText = false; val4.horizontalOverflow = (HorizontalWrapMode)1; val2.textComponent = val4; if (!string.IsNullOrEmpty(placeholder)) { GameObject val5 = new GameObject("Placeholder"); val5.transform.SetParent(val.transform, false); RectTransform obj3 = val5.AddComponent<RectTransform>(); obj3.anchorMin = Vector2.zero; obj3.anchorMax = Vector2.one; obj3.offsetMin = new Vector2(8f, 2f); obj3.offsetMax = new Vector2(-6f, -2f); Text val6 = val5.AddComponent<Text>(); val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); val6.fontSize = 14; ((Graphic)val6).color = Theme.TextMuted; val6.alignment = (TextAnchor)3; val6.supportRichText = false; val6.text = placeholder; val2.placeholder = (Graphic)(object)val6; } val2.lineType = (LineType)0; if (numeric) { val2.contentType = (ContentType)2; } if (characterLimit > 0) { val2.characterLimit = characterLimit; } val2.text = value ?? ""; if (onChange != null) { try { ((UnityEvent<string>)(object)val2.onEndEdit).AddListener(UnityAction<string>.op_Implicit((Action<string>)delegate(string s) { onChange(s); })); } catch { } } return val2; } public static GameObject FormRow(Transform parent, string label, string hint, out Transform controlSlot, bool stacked = false, float height = 50f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown GameObject val = new GameObject("formRow"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>(); float num = (stacked ? (height + 42f) : height); LayoutElement obj = val.AddComponent<LayoutElement>(); obj.minHeight = num; obj.preferredHeight = num; obj.flexibleWidth = 1f; if (stacked) { VerticalLayoutGroup obj2 = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; LabelBlock(val.transform, label, hint); GameObject val2 = new GameObject("control"); val2.transform.SetParent(val.transform, false); val2.AddComponent<RectTransform>(); LayoutElement obj3 = val2.AddComponent<LayoutElement>(); obj3.minHeight = 34f; obj3.preferredHeight = 34f; obj3.flexibleWidth = 1f; controlSlot = val2.transform; } else { HorizontalLayoutGroup obj4 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj4).spacing = 12f; ((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = true; ((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = false; ((LayoutGroup)obj4).childAlignment = (TextAnchor)3; LayoutElement component = LabelBlock(val.transform, label, hint).GetComponent<LayoutElement>(); component.minWidth = 0f; component.preferredWidth = 0f; component.flexibleWidth = 0.4f; GameObject val3 = new GameObject("control"); val3.transform.SetParent(val.transform, false); val3.AddComponent<RectTransform>(); LayoutElement obj5 = val3.AddComponent<LayoutElement>(); obj5.minWidth = 0f; obj5.preferredWidth = 0f; obj5.flexibleWidth = 0.6f; controlSlot = val3.transform; } return val; } public static void SectionHeader(Transform parent, string title) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("section"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>(); LayoutElement obj = val.AddComponent<LayoutElement>(); obj.minHeight = 30f; obj.preferredHeight = 30f; obj.flexibleWidth = 1f; VerticalLayoutGroup obj2 = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 3f; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((LayoutGroup)obj2).childAlignment = (TextAnchor)6; ((LayoutGroup)obj2).padding = new RectOffset(0, 0, 8, 0); Text obj3 = UIFactory.Text("title", (title ?? "").ToUpperInvariant(), val.transform, 11, (TextAnchor)6, (FontStyle)1); ((Graphic)obj3).color = Theme.Accent; ((Graphic)obj3).raycastTarget = false; LayoutElement obj4 = ((Component)obj3).gameObject.AddComponent<LayoutElement>(); obj4.minHeight = 16f; obj4.preferredHeight = 16f; GameObject val2 = new GameObject("divider"); val2.transform.SetParent(val.transform, false); val2.AddComponent<RectTransform>(); LayoutElement obj5 = val2.AddComponent<LayoutElement>(); obj5.minHeight = 1f; obj5.preferredHeight = 1f; obj5.flexibleWidth = 1f; Image obj6 = val2.AddComponent<Image>(); ((Graphic)obj6).color = Theme.AccentSubtle; ((Graphic)obj6).raycastTarget = false; } private static GameObject LabelBlock(Transform parent, string label, string hint) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("label"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>(); val.AddComponent<LayoutElement>(); VerticalLayoutGroup obj = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 1f; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((LayoutGroup)obj).childAlignment = (TextAnchor)3; Text obj2 = UIFactory.Text("l", label ?? "", val.transform, 14, (TextAnchor)3, (FontStyle)0); ((Graphic)obj2).color = Theme.TextPrimary; ((Graphic)obj2).raycastTarget = false; obj2.horizontalOverflow = (HorizontalWrapMode)0; obj2.verticalOverflow = (VerticalWrapMode)0; if (!string.IsNullOrEmpty(hint)) { Text obj3 = UIFactory.Text("h", hint, val.transform, 11, (TextAnchor)0, (FontStyle)0); ((Graphic)obj3).color = Theme.TextMuted; ((Graphic)obj3).raycastTarget = false; obj3.horizontalOverflow = (HorizontalWrapMode)0; obj3.verticalOverflow = (VerticalWrapMode)0; } return val; } public static void FillSlot(GameObject go, float vInset = 0f) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (((Object)(object)go != (Object)null) ? go.GetComponent<RectTransform>() : null); if (!((Object)(object)val == (Object)null)) { val.anchorMin = new Vector2(0f, 0f); val.anchorMax = new Vector2(1f, 1f); val.offsetMin = new Vector2(0f, vInset); val.offsetMax = new Vector2(0f, 0f - vInset); } } public static RectTransform ScrollList(Transform parent, out ScrollRect scroll, float spacing, Color backing) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) RectTransform result = ScrollList(parent, out scroll, spacing); try { GameObject obj = UIFactory.Panel("DD_ScrollBacking", parent, backing, (Vector2?)null, (Vector2?)null, true); Image component = obj.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = Theme.RoundedSprite(); component.type = (Type)1; ((Graphic)component).raycastTarget = false; } obj.transform.SetSiblingIndex(Mathf.Max(0, ((Component)scroll).transform.GetSiblingIndex())); } catch { } return result; } public static RectTransform ScrollList(Transform parent, out ScrollRect scroll, float spacing = 8f) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown RectTransform val = UIFactory.ScrollableVerticalList("DD_Scroll", parent, ref scroll); scroll.horizontal = false; scroll.movementType = (MovementType)2; scroll.scrollSensitivity = 24f; if ((Object)(object)scroll.viewport != (Object)null) { RectTransform viewport = scroll.viewport; viewport.anchorMin = Vector2.zero; viewport.anchorMax = Vector2.one; viewport.offsetMin = Vector2.zero; viewport.offsetMax = Vector2.zero; } val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(0.5f, 1f); val.offsetMin = new Vector2(0f, val.offsetMin.y); val.offsetMax = new Vector2(0f, val.offsetMax.y); VerticalLayoutGroup component = ((Component)val).GetComponent<VerticalLayoutGroup>(); if ((Object)(object)component != (Object)null) { ((HorizontalOrVerticalLayoutGroup)component).spacing = spacing; ((LayoutGroup)component).padding = new RectOffset(6, 12, 6, 6); ((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = true; } return val; } } public static class Toast { private class Entry { public GameObject go; public CanvasGroup cg; public float expire; } private const float Ttl = 3.4f; private const float FadeFor = 0.45f; private const float Width = 480f; private const float RowH = 40f; private const float Gap = 8f; private const float BaseY = 96f; private static Transform _host; private static readonly List<Entry> _entries = new List<Entry>(); public static void Init(Transform canvasRoot) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)canvasRoot == (Object)null) && !((Object)(object)_host != (Object)null)) { GameObject obj = UIFactory.Panel("DD_ToastHost", canvasRoot, Theme.Clear, (Vector2?)null, (Vector2?)null, true); Image component = obj.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { ((Graphic)component).raycastTarget = false; } obj.transform.SetAsLastSibling(); _host = obj.transform; } } public static void Clear() { _entries.Clear(); if ((Object)(object)_host != (Object)null) { Object.Destroy((Object)(object)((Component)_host).gameObject); _host = null; } } public static void Show(string message, Severity sev = Severity.Info) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_host == (Object)null) && !string.IsNullOrEmpty(message)) { Components.SeverityColors(sev, out var bar, out var _, out var _); GameObject val = UIFactory.Panel("toast", _host, Theme.BgElevated, (Vector2?)null, (Vector2?)null, false); Image component = val.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = Theme.RoundedSprite(); component.type = (Type)1; ((Graphic)component).raycastTarget = false; } RectTransform component2 = val.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.5f, 0f); component2.anchorMax = new Vector2(0.5f, 0f); component2.pivot = new Vector2(0.5f, 0f); component2.sizeDelta = new Vector2(480f, 40f); Outline obj = val.AddComponent<Outline>(); ((Shadow)obj).effectColor = Theme.HairlineStrong; ((Shadow)obj).effectDistance = new Vector2(1f, -1f); GameObject obj2 = UIFactory.Panel("bar", val.transform, bar, (Vector2?)null, (Vector2?)null, false); Image component3 = obj2.GetComponent<Image>(); if ((Object)(object)component3 != (Object)null) { ((Graphic)component3).raycastTarget = false; } RectTransform component4 = obj2.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 0f); component4.anchorMax = new Vector2(0f, 1f); component4.pivot = new Vector2(0f, 0.5f); component4.offsetMin = new Vector2(0f, 6f); component4.offsetMax = new Vector2(4f, -6f); Text obj3 = UIFactory.Text("t", message, val.transform, 13, (TextAnchor)3, (FontStyle)0); ((Graphic)obj3).color = Theme.TextPrimary; ((Graphic)obj3).raycastTarget = false; obj3.horizontalOverflow = (HorizontalWrapMode)0; obj3.verticalOverflow = (VerticalWrapMode)0; RectTransform rectTransform = ((Graphic)obj3).rectTransform; rectTransform.anchorMin = new Vector2(0f, 0f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.offsetMin = new Vector2(16f, 2f); rectTransform.offsetMax = new Vector2(-12f, -2f); CanvasGroup cg = val.AddComponent<CanvasGroup>(); _entries.Add(new Entry { go = val, cg = cg, expire = Time.time + 3.4f }); Reflow(); } } public static void Tick() { if (_entries.Count == 0) { return; } float time = Time.time; for (int num = _entries.Count - 1; num >= 0; num--) { Entry entry = _entries[num]; if ((Object)(object)entry.go == (Object)null) { _entries.RemoveAt(num); } else if (time >= entry.expire) { Object.Destroy((Object)(object)entry.go); _entries.RemoveAt(num); } else { float num2 = entry.expire - time; if ((Object)(object)entry.cg != (Object)null) { entry.cg.alpha = ((num2 < 0.45f) ? Mathf.Clamp01(num2 / 0.45f) : 1f); } } } Reflow(); } private static void Reflow() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) float num = 96f; for (int i = 0; i < _entries.Count; i++) { RectTransform val = (((Object)(object)_entries[i].go != (Object)null) ? _entries[i].go.GetComponent<RectTransform>() : null); if (!((Object)(object)val == (Object)null)) { val.anchoredPosition = new Vector2(0f, num); num += 48f; } } } } public static class SmoothScroll { private sealed class Entry { public ScrollRect sr; public float target; public bool animating; } private static readonly List<Entry> _entries = new List<Entry>(); private const float StepPx = 72f; private const float Ease = 16f; public static void Attach(ScrollRect s) { if ((Object)(object)s == (Object)null) { return; } for (int i = 0; i < _entries.Count; i++) { if ((Object)(object)_entries[i].sr == (Object)(object)s) { return; } } s.scrollSensitivity = 0f; s.movementType = (MovementType)2; _entries.Add(new Entry { sr = s }); } public static void Clear() { _entries.Clear(); } public static void Tick(Camera worldFallback = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (_entries.Count == 0) { return; } float y = Input.mouseScrollDelta.y; Vector2 val = Vector2.op_Implicit(Input.mousePosition); float num = Time.unscaledDeltaTime; if (num <= 0f) { num = 0.016f; } bool flag = Mathf.Abs(y) > 0.01f; for (int num2 = _entries.Count - 1; num2 >= 0; num2--) { Entry entry = _entries[num2]; if ((Object)(object)entry.sr == (Object)null || (Object)(object)entry.sr.content == (Object)null || (Object)(object)entry.sr.viewport == (Object)null) { _entries.RemoveAt(num2); } else { Camera val2 = null; Canvas componentInParent = ((Component)entry.sr.viewport).GetComponentInParent<Canvas>(); if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) { val2 = (((Object)(object)componentInParent.worldCamera != (Object)null) ? componentInParent.worldCamera : worldFallback); } Rect rect = entry.sr.content.rect; float height = ((Rect)(ref rect)).height; rect = entry.sr.viewport.rect; float num3 = Mathf.Max(0f, height - ((Rect)(ref rect)).height); if (flag && RectTransformUtility.RectangleContainsScreenPoint(entry.sr.viewport, val, val2)) { if (!entry.animating) { entry.target = entry.sr.content.anchoredPosition.y; } entry.target = Mathf.Clamp(entry.target - y * 72f, 0f, num3); entry.animating = true; } if (entry.animating) { Vector2 anchoredPosition = entry.sr.content.anchoredPosition; float num4 = Mathf.Lerp(anchoredPosition.y, Mathf.Clamp(entry.target, 0f, num3), 1f - Mathf.Exp(-16f * num)); if (Mathf.Abs(num4 - entry.target) < 0.5f) { num4 = entry.target; entry.animating = false; } anchoredPosition.y = num4; entry.sr.content
UserLibs/SixLabors.ImageSharp.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.Buffers.Binary; using System.Buffers.Text; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Numerics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.CodeAnalysis; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Companding; using SixLabors.ImageSharp.ColorSpaces.Conversion; using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Compression.Zlib; using SixLabors.ImageSharp.Diagnostics; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters; using SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder; using SixLabors.ImageSharp.Formats.Pbm; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png.Chunks; using SixLabors.ImageSharp.Formats.Png.Filters; using SixLabors.ImageSharp.Formats.Tga; using SixLabors.ImageSharp.Formats.Tiff; using SixLabors.ImageSharp.Formats.Tiff.Compression; using SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors; using SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors; using SixLabors.ImageSharp.Formats.Tiff.Constants; using SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; using SixLabors.ImageSharp.Formats.Tiff.Utils; using SixLabors.ImageSharp.Formats.Tiff.Writers; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Formats.Webp.BitReader; using SixLabors.ImageSharp.Formats.Webp.BitWriter; using SixLabors.ImageSharp.Formats.Webp.Lossless; using SixLabors.ImageSharp.Formats.Webp.Lossy; using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory.Internals; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Iptc; using SixLabors.ImageSharp.Metadata.Profiles.Xmp; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats.PixelBlenders; using SixLabors.ImageSharp.PixelFormats.Utils; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.ImageSharp.Processing.Processors.Binarization; using SixLabors.ImageSharp.Processing.Processors.Convolution; using SixLabors.ImageSharp.Processing.Processors.Convolution.Parameters; using SixLabors.ImageSharp.Processing.Processors.Dithering; using SixLabors.ImageSharp.Processing.Processors.Drawing; using SixLabors.ImageSharp.Processing.Processors.Effects; using SixLabors.ImageSharp.Processing.Processors.Filters; using SixLabors.ImageSharp.Processing.Processors.Normalization; using SixLabors.ImageSharp.Processing.Processors.Overlays; using SixLabors.ImageSharp.Processing.Processors.Quantization; using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Tuples; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v3.1", FrameworkDisplayName = ".NET Core 3.1")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] [assembly: InternalsVisibleTo("ImageSharp.Benchmarks, PublicKey=00240000048000009400000006020000002400005253413100040000010001000147e6fe6766715eec6cfed61f1e7dcdbf69748a3e355c67e9d8dfd953acab1d5e012ba34b23308166fdc61ee1d0390d5f36d814a6091dd4b5ed9eda5a26afced924c683b4bfb4b3d64b0586a57eff9f02b1f84e3cb0ddd518bd1697f2c84dcbb97eb8bb5c7801be12112ed0ec86db934b0e9a5171e6bb1384b6d2f7d54dfa97")] [assembly: InternalsVisibleTo("ImageSharp.Tests.ProfilingSandbox, PublicKey=00240000048000009400000006020000002400005253413100040000010001000147e6fe6766715eec6cfed61f1e7dcdbf69748a3e355c67e9d8dfd953acab1d5e012ba34b23308166fdc61ee1d0390d5f36d814a6091dd4b5ed9eda5a26afced924c683b4bfb4b3d64b0586a57eff9f02b1f84e3cb0ddd518bd1697f2c84dcbb97eb8bb5c7801be12112ed0ec86db934b0e9a5171e6bb1384b6d2f7d54dfa97")] [assembly: InternalsVisibleTo("SixLabors.ImageSharp.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001000147e6fe6766715eec6cfed61f1e7dcdbf69748a3e355c67e9d8dfd953acab1d5e012ba34b23308166fdc61ee1d0390d5f36d814a6091dd4b5ed9eda5a26afced924c683b4bfb4b3d64b0586a57eff9f02b1f84e3cb0ddd518bd1697f2c84dcbb97eb8bb5c7801be12112ed0ec86db934b0e9a5171e6bb1384b6d2f7d54dfa97")] [assembly: InternalsVisibleTo("SixLabors.ImageSharp.Drawing.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001000147e6fe6766715eec6cfed61f1e7dcdbf69748a3e355c67e9d8dfd953acab1d5e012ba34b23308166fdc61ee1d0390d5f36d814a6091dd4b5ed9eda5a26afced924c683b4bfb4b3d64b0586a57eff9f02b1f84e3cb0ddd518bd1697f2c84dcbb97eb8bb5c7801be12112ed0ec86db934b0e9a5171e6bb1384b6d2f7d54dfa97")] [assembly: AssemblyCompany("Six Labors")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © Six Labors")] [assembly: AssemblyDescription("A new, fully featured, fully managed, cross-platform, 2D graphics API for .NET")] [assembly: AssemblyFileVersion("2.1.9.0")] [assembly: AssemblyInformationalVersion("2.1.9+9816ca45016c5d3859986f3c600e8934bc450a56")] [assembly: AssemblyProduct("SixLabors.ImageSharp")] [assembly: AssemblyTitle("SixLabors.ImageSharp")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/SixLabors/ImageSharp")] [assembly: NeutralResourcesLanguage("en")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.0.0")] [assembly: TypeForwardedTo(typeof(ExcludeFromCodeCoverageAttribute))] [assembly: TypeForwardedTo(typeof(HashCode))] [assembly: TypeForwardedTo(typeof(MathF))] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } namespace SixLabors { [DebuggerStepThrough] internal static class DebugGuard { [Conditional("DEBUG")] public static void IsTrue(bool target, string message) { if (!target) { throw new InvalidOperationException(message); } } [Conditional("DEBUG")] public static void NotDisposed(bool isDisposed, string objectName) { if (isDisposed) { throw new ObjectDisposedException(objectName); } } [Conditional("DEBUG")] public static void MustBeSameSized<T>(ReadOnlySpan<T> target, ReadOnlySpan<T> other, string parameterName) where T : struct { if (target.Length != other.Length) { throw new ArgumentException("Span-s must be the same size!", parameterName); } } [Conditional("DEBUG")] public static void MustBeSizedAtLeast<T>(ReadOnlySpan<T> target, ReadOnlySpan<T> minSpan, string parameterName) where T : struct { if (target.Length < minSpan.Length) { throw new ArgumentException($"Span-s must be at least of length {minSpan.Length}!", parameterName); } } [Conditional("DEBUG")] public static void NotNull<TValue>(TValue value, string parameterName) where TValue : class { if (value == null) { ThrowArgumentNullException(parameterName); } } [Conditional("DEBUG")] public static void NotNullOrWhiteSpace(string value, string parameterName) { if (value == null) { ThrowArgumentNullException(parameterName); } if (string.IsNullOrWhiteSpace(value)) { ThrowArgumentException("Must not be empty or whitespace.", parameterName); } } [Conditional("DEBUG")] public static void MustBeLessThan<TValue>(TValue value, TValue max, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(max) >= 0) { ThrowArgumentOutOfRangeException(parameterName, $"Value {value} must be less than {max}."); } } [Conditional("DEBUG")] public static void MustBeLessThanOrEqualTo<TValue>(TValue value, TValue max, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(max) > 0) { ThrowArgumentOutOfRangeException(parameterName, $"Value {value} must be less than or equal to {max}."); } } [Conditional("DEBUG")] public static void MustBeGreaterThan<TValue>(TValue value, TValue min, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(min) <= 0) { ThrowArgumentOutOfRangeException(parameterName, $"Value {value} must be greater than {min}."); } } [Conditional("DEBUG")] public static void MustBeGreaterThanOrEqualTo<TValue>(TValue value, TValue min, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(min) < 0) { ThrowArgumentOutOfRangeException(parameterName, $"Value {value} must be greater than or equal to {min}."); } } [Conditional("DEBUG")] public static void MustBeBetweenOrEqualTo<TValue>(TValue value, TValue min, TValue max, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(min) < 0 || value.CompareTo(max) > 0) { ThrowArgumentOutOfRangeException(parameterName, $"Value {value} must be greater than or equal to {min} and less than or equal to {max}."); } } [Conditional("DEBUG")] public static void IsTrue(bool target, string parameterName, string message) { if (!target) { ThrowArgumentException(message, parameterName); } } [Conditional("DEBUG")] public static void IsFalse(bool target, string parameterName, string message) { if (target) { ThrowArgumentException(message, parameterName); } } [Conditional("DEBUG")] public static void MustBeSizedAtLeast<T>(ReadOnlySpan<T> source, int minLength, string parameterName) { if (source.Length < minLength) { ThrowArgumentException($"Span-s must be at least of length {minLength}!", parameterName); } } [Conditional("DEBUG")] public static void MustBeSizedAtLeast<T>(Span<T> source, int minLength, string parameterName) { if (source.Length < minLength) { ThrowArgumentException($"The size must be at least {minLength}.", parameterName); } } [Conditional("DEBUG")] public static void DestinationShouldNotBeTooShort<TSource, TDest>(ReadOnlySpan<TSource> source, Span<TDest> destination, string destinationParamName) { if (destination.Length < source.Length) { ThrowArgumentException("Destination span is too short!", destinationParamName); } } [Conditional("DEBUG")] public static void DestinationShouldNotBeTooShort<TSource, TDest>(Span<TSource> source, Span<TDest> destination, string destinationParamName) { if (destination.Length < source.Length) { ThrowArgumentException("Destination span is too short!", destinationParamName); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void ThrowArgumentException(string message, string parameterName) { throw new ArgumentException(message, parameterName); } [MethodImpl(MethodImplOptions.NoInlining)] private static void ThrowArgumentOutOfRangeException(string parameterName, string message) { throw new ArgumentOutOfRangeException(parameterName, message); } [MethodImpl(MethodImplOptions.NoInlining)] private static void ThrowArgumentNullException(string parameterName) { throw new ArgumentNullException(parameterName); } } [DebuggerStepThrough] internal static class Guard { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeValueType<TValue>(TValue value, string parameterName) { if (!value.GetType().IsValueType) { ThrowHelper.ThrowArgumentException("Type must be a struct.", parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void NotNull<TValue>(TValue value, string parameterName) where TValue : class { if (value == null) { ThrowHelper.ThrowArgumentNullExceptionForNotNull(parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void NotNullOrWhiteSpace(string value, string parameterName) { if (string.IsNullOrWhiteSpace(value)) { ThrowHelper.ThrowArgumentExceptionForNotNullOrWhitespace(value, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan<TValue>(TValue value, TValue max, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(max) >= 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo<TValue>(TValue value, TValue max, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(max) > 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan<TValue>(TValue value, TValue min, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(min) <= 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo<TValue>(TValue value, TValue min, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(min) < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo<TValue>(TValue value, TValue min, TValue max, string parameterName) where TValue : IComparable<TValue> { if (value.CompareTo(min) < 0 || value.CompareTo(max) > 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsTrue(bool target, string parameterName, string message) { if (!target) { ThrowHelper.ThrowArgumentException(message, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void IsFalse(bool target, string parameterName, string message) { if (target) { ThrowHelper.ThrowArgumentException(message, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeSizedAtLeast<T>(ReadOnlySpan<T> source, int minLength, string parameterName) { if (source.Length < minLength) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeSizedAtLeast(minLength, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeSizedAtLeast<T>(Span<T> source, int minLength, string parameterName) { if (source.Length < minLength) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeSizedAtLeast(minLength, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void DestinationShouldNotBeTooShort<TSource, TDest>(ReadOnlySpan<TSource> source, Span<TDest> destination, string destinationParamName) { if (destination.Length < source.Length) { ThrowHelper.ThrowArgumentException("Destination span is too short!", destinationParamName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void DestinationShouldNotBeTooShort<TSource, TDest>(Span<TSource> source, Span<TDest> destination, string destinationParamName) { if (destination.Length < source.Length) { ThrowHelper.ThrowArgumentException("Destination span is too short!", destinationParamName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(byte value, byte max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(byte value, byte max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(byte value, byte min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(byte value, byte min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(byte value, byte min, byte max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(sbyte value, sbyte max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(sbyte value, sbyte max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(sbyte value, sbyte min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(sbyte value, sbyte min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(sbyte value, sbyte min, sbyte max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(short value, short max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(short value, short max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(short value, short min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(short value, short min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(short value, short min, short max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(ushort value, ushort max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(ushort value, ushort max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(ushort value, ushort min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(ushort value, ushort min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(ushort value, ushort min, ushort max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(char value, char max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(char value, char max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(char value, char min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(char value, char min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(char value, char min, char max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(int value, int max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(int value, int max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(int value, int min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(int value, int min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(int value, int min, int max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(uint value, uint max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(uint value, uint max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(uint value, uint min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(uint value, uint min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(uint value, uint min, uint max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(float value, float max, string parameterName) { if (!(value < max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(float value, float max, string parameterName) { if (!(value <= max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(float value, float min, string parameterName) { if (!(value > min)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(float value, float min, string parameterName) { if (!(value >= min)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(float value, float min, float max, string parameterName) { if (!(value >= min) || !(value <= max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(long value, long max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(long value, long max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(long value, long min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(long value, long min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(long value, long min, long max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(ulong value, ulong max, string parameterName) { if (value >= max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(ulong value, ulong max, string parameterName) { if (value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(ulong value, ulong min, string parameterName) { if (value <= min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(ulong value, ulong min, string parameterName) { if (value < min) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(ulong value, ulong min, ulong max, string parameterName) { if (value < min || value > max) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(double value, double max, string parameterName) { if (!(value < max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(double value, double max, string parameterName) { if (!(value <= max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(double value, double min, string parameterName) { if (!(value > min)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(double value, double min, string parameterName) { if (!(value >= min)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(double value, double min, double max, string parameterName) { if (!(value >= min) || !(value <= max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThan(decimal value, decimal max, string parameterName) { if (!(value < max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeLessThanOrEqualTo(decimal value, decimal max, string parameterName) { if (!(value <= max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThan(decimal value, decimal min, string parameterName) { if (!(value > min)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeGreaterThanOrEqualTo(decimal value, decimal min, string parameterName) { if (!(value >= min)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MustBeBetweenOrEqualTo(decimal value, decimal min, decimal max, string parameterName) { if (!(value >= min) || !(value <= max)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName); } } } internal static class ThrowHelper { [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentNullExceptionForNotNull(string name) { ThrowArgumentNullException(name, "Parameter \"" + name + "\" must be not null."); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentExceptionForNotNullOrWhitespace(string value, string name) { if (value == null) { ThrowArgumentNullException(name, "Parameter \"" + name + "\" must be not null."); } else { ThrowArgumentException(name, "Parameter \"" + name + "\" must not be empty or whitespace."); } } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentOutOfRangeExceptionForMustBeLessThan<T>(T value, T max, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter \"{name}\" ({typeof(T)}) must be less than {max}, was {value}"); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo<T>(T value, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter \"{name}\" ({typeof(T)}) must be less than or equal to {maximum}, was {value}"); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan<T>(T value, T minimum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter \"{name}\" ({typeof(T)}) must be greater than {minimum}, was {value}"); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo<T>(T value, T minimum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter \"{name}\" ({typeof(T)}) must be greater than or equal to {minimum}, was {value}"); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo<T>(T value, T minimum, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter \"{name}\" ({typeof(T)}) must be between or equal to {minimum} and {maximum}, was {value}"); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentOutOfRangeExceptionForMustBeSizedAtLeast(int minLength, string parameterName) { ThrowArgumentException($"Spans must be at least of length {minLength}!", parameterName); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentException(string message, string name) { throw new ArgumentException(message, name); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentNullException(string name, string message) { throw new ArgumentNullException(name, message); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentOutOfRangeException(string name, string message) { throw new ArgumentOutOfRangeException(name, message); } } } namespace SixLabors.ImageSharp { public readonly struct Color : IEquatable<Color> { private readonly Rgba64 data; private readonly IPixel boxedHighPrecisionPixel; private static readonly Lazy<Dictionary<string, Color>> NamedColorsLookupLazy = new Lazy<Dictionary<string, Color>>(CreateNamedColorsLookup, isThreadSafe: true); public static readonly Color AliceBlue = FromRgba(240, 248, byte.MaxValue, byte.MaxValue); public static readonly Color AntiqueWhite = FromRgba(250, 235, 215, byte.MaxValue); public static readonly Color Aqua = FromRgba(0, byte.MaxValue, byte.MaxValue, byte.MaxValue); public static readonly Color Aquamarine = FromRgba(127, byte.MaxValue, 212, byte.MaxValue); public static readonly Color Azure = FromRgba(240, byte.MaxValue, byte.MaxValue, byte.MaxValue); public static readonly Color Beige = FromRgba(245, 245, 220, byte.MaxValue); public static readonly Color Bisque = FromRgba(byte.MaxValue, 228, 196, byte.MaxValue); public static readonly Color Black = FromRgba(0, 0, 0, byte.MaxValue); public static readonly Color BlanchedAlmond = FromRgba(byte.MaxValue, 235, 205, byte.MaxValue); public static readonly Color Blue = FromRgba(0, 0, byte.MaxValue, byte.MaxValue); public static readonly Color BlueViolet = FromRgba(138, 43, 226, byte.MaxValue); public static readonly Color Brown = FromRgba(165, 42, 42, byte.MaxValue); public static readonly Color BurlyWood = FromRgba(222, 184, 135, byte.MaxValue); public static readonly Color CadetBlue = FromRgba(95, 158, 160, byte.MaxValue); public static readonly Color Chartreuse = FromRgba(127, byte.MaxValue, 0, byte.MaxValue); public static readonly Color Chocolate = FromRgba(210, 105, 30, byte.MaxValue); public static readonly Color Coral = FromRgba(byte.MaxValue, 127, 80, byte.MaxValue); public static readonly Color CornflowerBlue = FromRgba(100, 149, 237, byte.MaxValue); public static readonly Color Cornsilk = FromRgba(byte.MaxValue, 248, 220, byte.MaxValue); public static readonly Color Crimson = FromRgba(220, 20, 60, byte.MaxValue); public static readonly Color Cyan = Aqua; public static readonly Color DarkBlue = FromRgba(0, 0, 139, byte.MaxValue); public static readonly Color DarkCyan = FromRgba(0, 139, 139, byte.MaxValue); public static readonly Color DarkGoldenrod = FromRgba(184, 134, 11, byte.MaxValue); public static readonly Color DarkGray = FromRgba(169, 169, 169, byte.MaxValue); public static readonly Color DarkGreen = FromRgba(0, 100, 0, byte.MaxValue); public static readonly Color DarkGrey = DarkGray; public static readonly Color DarkKhaki = FromRgba(189, 183, 107, byte.MaxValue); public static readonly Color DarkMagenta = FromRgba(139, 0, 139, byte.MaxValue); public static readonly Color DarkOliveGreen = FromRgba(85, 107, 47, byte.MaxValue); public static readonly Color DarkOrange = FromRgba(byte.MaxValue, 140, 0, byte.MaxValue); public static readonly Color DarkOrchid = FromRgba(153, 50, 204, byte.MaxValue); public static readonly Color DarkRed = FromRgba(139, 0, 0, byte.MaxValue); public static readonly Color DarkSalmon = FromRgba(233, 150, 122, byte.MaxValue); public static readonly Color DarkSeaGreen = FromRgba(143, 188, 143, byte.MaxValue); public static readonly Color DarkSlateBlue = FromRgba(72, 61, 139, byte.MaxValue); public static readonly Color DarkSlateGray = FromRgba(47, 79, 79, byte.MaxValue); public static readonly Color DarkSlateGrey = DarkSlateGray; public static readonly Color DarkTurquoise = FromRgba(0, 206, 209, byte.MaxValue); public static readonly Color DarkViolet = FromRgba(148, 0, 211, byte.MaxValue); public static readonly Color DeepPink = FromRgba(byte.MaxValue, 20, 147, byte.MaxValue); public static readonly Color DeepSkyBlue = FromRgba(0, 191, byte.MaxValue, byte.MaxValue); public static readonly Color DimGray = FromRgba(105, 105, 105, byte.MaxValue); public static readonly Color DimGrey = DimGray; public static readonly Color DodgerBlue = FromRgba(30, 144, byte.MaxValue, byte.MaxValue); public static readonly Color Firebrick = FromRgba(178, 34, 34, byte.MaxValue); public static readonly Color FloralWhite = FromRgba(byte.MaxValue, 250, 240, byte.MaxValue); public static readonly Color ForestGreen = FromRgba(34, 139, 34, byte.MaxValue); public static readonly Color Fuchsia = FromRgba(byte.MaxValue, 0, byte.MaxValue, byte.MaxValue); public static readonly Color Gainsboro = FromRgba(220, 220, 220, byte.MaxValue); public static readonly Color GhostWhite = FromRgba(248, 248, byte.MaxValue, byte.MaxValue); public static readonly Color Gold = FromRgba(byte.MaxValue, 215, 0, byte.MaxValue); public static readonly Color Goldenrod = FromRgba(218, 165, 32, byte.MaxValue); public static readonly Color Gray = FromRgba(128, 128, 128, byte.MaxValue); public static readonly Color Green = FromRgba(0, 128, 0, byte.MaxValue); public static readonly Color GreenYellow = FromRgba(173, byte.MaxValue, 47, byte.MaxValue); public static readonly Color Grey = Gray; public static readonly Color Honeydew = FromRgba(240, byte.MaxValue, 240, byte.MaxValue); public static readonly Color HotPink = FromRgba(byte.MaxValue, 105, 180, byte.MaxValue); public static readonly Color IndianRed = FromRgba(205, 92, 92, byte.MaxValue); public static readonly Color Indigo = FromRgba(75, 0, 130, byte.MaxValue); public static readonly Color Ivory = FromRgba(byte.MaxValue, byte.MaxValue, 240, byte.MaxValue); public static readonly Color Khaki = FromRgba(240, 230, 140, byte.MaxValue); public static readonly Color Lavender = FromRgba(230, 230, 250, byte.MaxValue); public static readonly Color LavenderBlush = FromRgba(byte.MaxValue, 240, 245, byte.MaxValue); public static readonly Color LawnGreen = FromRgba(124, 252, 0, byte.MaxValue); public static readonly Color LemonChiffon = FromRgba(byte.MaxValue, 250, 205, byte.MaxValue); public static readonly Color LightBlue = FromRgba(173, 216, 230, byte.MaxValue); public static readonly Color LightCoral = FromRgba(240, 128, 128, byte.MaxValue); public static readonly Color LightCyan = FromRgba(224, byte.MaxValue, byte.MaxValue, byte.MaxValue); public static readonly Color LightGoldenrodYellow = FromRgba(250, 250, 210, byte.MaxValue); public static readonly Color LightGray = FromRgba(211, 211, 211, byte.MaxValue); public static readonly Color LightGreen = FromRgba(144, 238, 144, byte.MaxValue); public static readonly Color LightGrey = LightGray; public static readonly Color LightPink = FromRgba(byte.MaxValue, 182, 193, byte.MaxValue); public static readonly Color LightSalmon = FromRgba(byte.MaxValue, 160, 122, byte.MaxValue); public static readonly Color LightSeaGreen = FromRgba(32, 178, 170, byte.MaxValue); public static readonly Color LightSkyBlue = FromRgba(135, 206, 250, byte.MaxValue); public static readonly Color LightSlateGray = FromRgba(119, 136, 153, byte.MaxValue); public static readonly Color LightSlateGrey = LightSlateGray; public static readonly Color LightSteelBlue = FromRgba(176, 196, 222, byte.MaxValue); public static readonly Color LightYellow = FromRgba(byte.MaxValue, byte.MaxValue, 224, byte.MaxValue); public static readonly Color Lime = FromRgba(0, byte.MaxValue, 0, byte.MaxValue); public static readonly Color LimeGreen = FromRgba(50, 205, 50, byte.MaxValue); public static readonly Color Linen = FromRgba(250, 240, 230, byte.MaxValue); public static readonly Color Magenta = Fuchsia; public static readonly Color Maroon = FromRgba(128, 0, 0, byte.MaxValue); public static readonly Color MediumAquamarine = FromRgba(102, 205, 170, byte.MaxValue); public static readonly Color MediumBlue = FromRgba(0, 0, 205, byte.MaxValue); public static readonly Color MediumOrchid = FromRgba(186, 85, 211, byte.MaxValue); public static readonly Color MediumPurple = FromRgba(147, 112, 219, byte.MaxValue); public static readonly Color MediumSeaGreen = FromRgba(60, 179, 113, byte.MaxValue); public static readonly Color MediumSlateBlue = FromRgba(123, 104, 238, byte.MaxValue); public static readonly Color MediumSpringGreen = FromRgba(0, 250, 154, byte.MaxValue); public static readonly Color MediumTurquoise = FromRgba(72, 209, 204, byte.MaxValue); public static readonly Color MediumVioletRed = FromRgba(199, 21, 133, byte.MaxValue); public static readonly Color MidnightBlue = FromRgba(25, 25, 112, byte.MaxValue); public static readonly Color MintCream = FromRgba(245, byte.MaxValue, 250, byte.MaxValue); public static readonly Color MistyRose = FromRgba(byte.MaxValue, 228, 225, byte.MaxValue); public static readonly Color Moccasin = FromRgba(byte.MaxValue, 228, 181, byte.MaxValue); public static readonly Color NavajoWhite = FromRgba(byte.MaxValue, 222, 173, byte.MaxValue); public static readonly Color Navy = FromRgba(0, 0, 128, byte.MaxValue); public static readonly Color OldLace = FromRgba(253, 245, 230, byte.MaxValue); public static readonly Color Olive = FromRgba(128, 128, 0, byte.MaxValue); public static readonly Color OliveDrab = FromRgba(107, 142, 35, byte.MaxValue); public static readonly Color Orange = FromRgba(byte.MaxValue, 165, 0, byte.MaxValue); public static readonly Color OrangeRed = FromRgba(byte.MaxValue, 69, 0, byte.MaxValue); public static readonly Color Orchid = FromRgba(218, 112, 214, byte.MaxValue); public static readonly Color PaleGoldenrod = FromRgba(238, 232, 170, byte.MaxValue); public static readonly Color PaleGreen = FromRgba(152, 251, 152, byte.MaxValue); public static readonly Color PaleTurquoise = FromRgba(175, 238, 238, byte.MaxValue); public static readonly Color PaleVioletRed = FromRgba(219, 112, 147, byte.MaxValue); public static readonly Color PapayaWhip = FromRgba(byte.MaxValue, 239, 213, byte.MaxValue); public static readonly Color PeachPuff = FromRgba(byte.MaxValue, 218, 185, byte.MaxValue); public static readonly Color Peru = FromRgba(205, 133, 63, byte.MaxValue); public static readonly Color Pink = FromRgba(byte.MaxValue, 192, 203, byte.MaxValue); public static readonly Color Plum = FromRgba(221, 160, 221, byte.MaxValue); public static readonly Color PowderBlue = FromRgba(176, 224, 230, byte.MaxValue); public static readonly Color Purple = FromRgba(128, 0, 128, byte.MaxValue); public static readonly Color RebeccaPurple = FromRgba(102, 51, 153, byte.MaxValue); public static readonly Color Red = FromRgba(byte.MaxValue, 0, 0, byte.MaxValue); public static readonly Color RosyBrown = FromRgba(188, 143, 143, byte.MaxValue); public static readonly Color RoyalBlue = FromRgba(65, 105, 225, byte.MaxValue); public static readonly Color SaddleBrown = FromRgba(139, 69, 19, byte.MaxValue); public static readonly Color Salmon = FromRgba(250, 128, 114, byte.MaxValue); public static readonly Color SandyBrown = FromRgba(244, 164, 96, byte.MaxValue); public static readonly Color SeaGreen = FromRgba(46, 139, 87, byte.MaxValue); public static readonly Color SeaShell = FromRgba(byte.MaxValue, 245, 238, byte.MaxValue); public static readonly Color Sienna = FromRgba(160, 82, 45, byte.MaxValue); public static readonly Color Silver = FromRgba(192, 192, 192, byte.MaxValue); public static readonly Color SkyBlue = FromRgba(135, 206, 235, byte.MaxValue); public static readonly Color SlateBlue = FromRgba(106, 90, 205, byte.MaxValue); public static readonly Color SlateGray = FromRgba(112, 128, 144, byte.MaxValue); public static readonly Color SlateGrey = SlateGray; public static readonly Color Snow = FromRgba(byte.MaxValue, 250, 250, byte.MaxValue); public static readonly Color SpringGreen = FromRgba(0, byte.MaxValue, 127, byte.MaxValue); public static readonly Color SteelBlue = FromRgba(70, 130, 180, byte.MaxValue); public static readonly Color Tan = FromRgba(210, 180, 140, byte.MaxValue); public static readonly Color Teal = FromRgba(0, 128, 128, byte.MaxValue); public static readonly Color Thistle = FromRgba(216, 191, 216, byte.MaxValue); public static readonly Color Tomato = FromRgba(byte.MaxValue, 99, 71, byte.MaxValue); public static readonly Color Transparent = FromRgba(0, 0, 0, 0); public static readonly Color Turquoise = FromRgba(64, 224, 208, byte.MaxValue); public static readonly Color Violet = FromRgba(238, 130, 238, byte.MaxValue); public static readonly Color Wheat = FromRgba(245, 222, 179, byte.MaxValue); public static readonly Color White = FromRgba(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); public static readonly Color WhiteSmoke = FromRgba(245, 245, 245, byte.MaxValue); public static readonly Color Yellow = FromRgba(byte.MaxValue, byte.MaxValue, 0, byte.MaxValue); public static readonly Color YellowGreen = FromRgba(154, 205, 50, byte.MaxValue); private static readonly Lazy<Color[]> WebSafePaletteLazy = new Lazy<Color[]>(CreateWebSafePalette, isThreadSafe: true); private static readonly Lazy<Color[]> WernerPaletteLazy = new Lazy<Color[]>(CreateWernerPalette, isThreadSafe: true); public static ReadOnlyMemory<Color> WebSafePalette => WebSafePaletteLazy.Value; public static ReadOnlyMemory<Color> WernerPalette => WernerPaletteLazy.Value; [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Rgba64 pixel) { data = pixel; boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Rgb48 pixel) { data = new Rgba64(pixel.R, pixel.G, pixel.B, ushort.MaxValue); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(La32 pixel) { data = new Rgba64(pixel.L, pixel.L, pixel.L, pixel.A); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(L16 pixel) { data = new Rgba64(pixel.PackedValue, pixel.PackedValue, pixel.PackedValue, ushort.MaxValue); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Rgba32 pixel) { data = new Rgba64(pixel); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Argb32 pixel) { data = new Rgba64(pixel); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Bgra32 pixel) { data = new Rgba64(pixel); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Abgr32 pixel) { data = new Rgba64(pixel); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Rgb24 pixel) { data = new Rgba64(pixel); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Bgr24 pixel) { data = new Rgba64(pixel); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color(Vector4 vector) { vector = Numerics.Clamp(vector, Vector4.Zero, Vector4.One); boxedHighPrecisionPixel = new RgbaVector(vector.X, vector.Y, vector.Z, vector.W); data = default(Rgba64); } public static explicit operator Vector4(Color color) { return color.ToVector4(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator Color(Vector4 source) { return new Color(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Rgba32 ToRgba32() { if (boxedHighPrecisionPixel == null) { return data.ToRgba32(); } Rgba32 dest = default(Rgba32); boxedHighPrecisionPixel.ToRgba32(ref dest); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Bgra32 ToBgra32() { if (boxedHighPrecisionPixel == null) { return data.ToBgra32(); } Bgra32 result = default(Bgra32); result.FromScaledVector4(boxedHighPrecisionPixel.ToScaledVector4()); return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Argb32 ToArgb32() { if (boxedHighPrecisionPixel == null) { return data.ToArgb32(); } Argb32 result = default(Argb32); result.FromScaledVector4(boxedHighPrecisionPixel.ToScaledVector4()); return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Abgr32 ToAbgr32() { if (boxedHighPrecisionPixel == null) { return data.ToAbgr32(); } Abgr32 result = default(Abgr32); result.FromScaledVector4(boxedHighPrecisionPixel.ToScaledVector4()); return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Rgb24 ToRgb24() { if (boxedHighPrecisionPixel == null) { return data.ToRgb24(); } Rgb24 result = default(Rgb24); result.FromScaledVector4(boxedHighPrecisionPixel.ToScaledVector4()); return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Bgr24 ToBgr24() { if (boxedHighPrecisionPixel == null) { return data.ToBgr24(); } Bgr24 result = default(Bgr24); result.FromScaledVector4(boxedHighPrecisionPixel.ToScaledVector4()); return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Vector4 ToVector4() { if (boxedHighPrecisionPixel == null) { return data.ToScaledVector4(); } return boxedHighPrecisionPixel.ToScaledVector4(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private Color(byte r, byte g, byte b, byte a) { data = new Rgba64(ColorNumerics.UpscaleFrom8BitTo16Bit(r), ColorNumerics.UpscaleFrom8BitTo16Bit(g), ColorNumerics.UpscaleFrom8BitTo16Bit(b), ColorNumerics.UpscaleFrom8BitTo16Bit(a)); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private Color(byte r, byte g, byte b) { data = new Rgba64(ColorNumerics.UpscaleFrom8BitTo16Bit(r), ColorNumerics.UpscaleFrom8BitTo16Bit(g), ColorNumerics.UpscaleFrom8BitTo16Bit(b), ushort.MaxValue); boxedHighPrecisionPixel = null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private Color(IPixel pixel) { boxedHighPrecisionPixel = pixel; data = default(Rgba64); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(Color left, Color right) { return left.Equals(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(Color left, Color right) { return !left.Equals(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Color FromRgba(byte r, byte g, byte b, byte a) { return new Color(r, g, b, a); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Color FromRgb(byte r, byte g, byte b) { return new Color(r, g, b); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Color FromPixel<TPixel>(TPixel pixel) where TPixel : unmanaged, IPixel<TPixel> { if (typeof(TPixel) == typeof(Rgba64)) { return new Color((Rgba64)(object)pixel); } if (typeof(TPixel) == typeof(Rgb48)) { return new Color((Rgb48)(object)pixel); } if (typeof(TPixel) == typeof(La32)) { return new Color((La32)(object)pixel); } if (typeof(TPixel) == typeof(L16)) { return new Color((L16)(object)pixel); } if (Unsafe.SizeOf<TPixel>() <= Unsafe.SizeOf<Rgba32>()) { Rgba32 dest = default(Rgba32); pixel.ToRgba32(ref dest); return new Color(dest); } return new Color(pixel); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Color ParseHex(string hex) { return new Color(Rgba32.ParseHex(hex)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseHex(string hex, out Color result) { result = default(Color); if (Rgba32.TryParseHex(hex, out var result2)) { result = new Color(result2); return true; } return false; } public static Color Parse(string input) { Guard.NotNull(input, "input"); if (!TryParse(input, out var result)) { throw new ArgumentException("Input string is not in the correct format.", "input"); } return result; } public static bool TryParse(string input, out Color result) { result = default(Color); if (string.IsNullOrWhiteSpace(input)) { return false; } if (NamedColorsLookupLazy.Value.TryGetValue(input, out result)) { return true; } return TryParseHex(input, out result); } public Color WithAlpha(float alpha) { Vector4 vector = (Vector4)this; vector.W = alpha; return new Color(vector); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public string ToHex() { return data.ToRgba32().ToHex(); } public override string ToString() { return ToHex(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public TPixel ToPixel<TPixel>() where TPixel : unmanaged, IPixel<TPixel> { IPixel pixel = boxedHighPrecisionPixel; if (pixel is TPixel) { return (TPixel)pixel; } TPixel result; if (boxedHighPrecisionPixel == null) { result = default(TPixel); result.FromRgba64(data); return result; } result = default(TPixel); result.FromScaledVector4(boxedHighPrecisionPixel.ToScaledVector4()); return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ToPixel<TPixel>(Configuration configuration, ReadOnlySpan<Color> source, Span<TPixel> destination) where TPixel : unmanaged, IPixel<TPixel> { Guard.DestinationShouldNotBeTooShort(source, destination, "destination"); for (int i = 0; i < source.Length; i++) { destination[i] = source[i].ToPixel<TPixel>(); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(Color other) { if (boxedHighPrecisionPixel == null && other.boxedHighPrecisionPixel == null) { return data.PackedValue == other.data.PackedValue; } return boxedHighPrecisionPixel?.Equals(other.boxedHighPrecisionPixel) ?? false; } public override bool Equals(object obj) { if (obj is Color other) { return Equals(other); } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override int GetHashCode() { if (boxedHighPrecisionPixel == null) { return data.PackedValue.GetHashCode(); } return boxedHighPrecisionPixel.GetHashCode(); } private static Dictionary<string, Color> CreateNamedColorsLookup() { return new Dictionary<string, Color>(StringComparer.OrdinalIgnoreCase) { { "AliceBlue", AliceBlue }, { "AntiqueWhite", AntiqueWhite }, { "Aqua", Aqua }, { "Aquamarine", Aquamarine }, { "Azure", Azure }, { "Beige", Beige }, { "Bisque", Bisque }, { "Black", Black }, { "BlanchedAlmond", BlanchedAlmond }, { "Blue", Blue }, { "BlueViolet", BlueViolet }, { "Brown", Brown }, { "BurlyWood", BurlyWood }, { "CadetBlue", CadetBlue }, { "Chartreuse", Chartreuse }, { "Chocolate", Chocolate }, { "Coral", Coral }, { "CornflowerBlue", CornflowerBlue }, { "Cornsilk", Cornsilk }, { "Crimson", Crimson }, { "Cyan", Cyan }, { "DarkBlue", DarkBlue }, { "DarkCyan", DarkCyan }, { "DarkGoldenrod", DarkGoldenrod }, { "DarkGray", DarkGray }, { "DarkGreen", DarkGreen }, { "DarkGrey", DarkGrey }, { "DarkKhaki", DarkKhaki }, { "DarkMagenta", DarkMagenta }, { "DarkOliveGreen", DarkOliveGreen }, { "DarkOrange", DarkOrange }, { "DarkOrchid", DarkOrchid }, { "DarkRed", DarkRed }, { "DarkSalmon", DarkSalmon }, { "DarkSeaGreen", DarkSeaGreen }, { "DarkSlateBlue", DarkSlateBlue }, { "DarkSlateGray", DarkSlateGray }, { "DarkSlateGrey", DarkSlateGrey }, { "DarkTurquoise", DarkTurquoise }, { "DarkViolet", DarkViolet }, { "DeepPink", DeepPink }, { "DeepSkyBlue", DeepSkyBlue }, { "DimGray", DimGray }, { "DimGrey", DimGrey }, { "DodgerBlue", DodgerBlue }, { "Firebrick", Firebrick }, { "FloralWhite", FloralWhite }, { "ForestGreen", ForestGreen }, { "Fuchsia", Fuchsia }, { "Gainsboro", Gainsboro }, { "GhostWhite", GhostWhite }, { "Gold", Gold }, { "Goldenrod", Goldenrod }, { "Gray", Gray }, { "Green", Green }, { "GreenYellow", GreenYellow }, { "Grey", Grey }, { "Honeydew", Honeydew }, { "HotPink", HotPink }, { "IndianRed", IndianRed }, { "Indigo", Indigo }, { "Ivory", Ivory }, { "Khaki", Khaki }, { "Lavender", Lavender }, { "LavenderBlush", LavenderBlush }, { "LawnGreen", LawnGreen }, { "LemonChiffon", LemonChiffon }, { "LightBlue", LightBlue }, { "LightCoral", LightCoral }, { "LightCyan", LightCyan }, { "LightGoldenrodYellow", LightGoldenrodYellow }, { "LightGray", LightGray }, { "LightGreen", LightGreen }, { "LightGrey", LightGrey }, { "LightPink", LightPink }, { "LightSalmon", LightSalmon }, { "LightSeaGreen", LightSeaGreen }, { "LightSkyBlue", LightSkyBlue }, { "LightSlateGray", LightSlateGray }, { "LightSlateGrey", LightSlateGrey }, { "LightSteelBlue", LightSteelBlue }, { "LightYellow", LightYellow }, { "Lime", Lime }, { "LimeGreen", LimeGreen }, { "Linen", Linen }, { "Magenta", Magenta }, { "Maroon", Maroon }, { "MediumAquamarine", MediumAquamarine }, { "MediumBlue", MediumBlue }, { "MediumOrchid", MediumOrchid }, { "MediumPurple", MediumPurple }, { "MediumSeaGreen", MediumSeaGreen }, { "MediumSlateBlue", MediumSlateBlue }, { "MediumSpringGreen", MediumSpringGreen }, { "MediumTurquoise", MediumTurquoise }, { "MediumVioletRed", MediumVioletRed }, { "MidnightBlue", MidnightBlue }, { "MintCream", MintCream }, { "MistyRose", MistyRose }, { "Moccasin", Moccasin }, { "NavajoWhite", NavajoWhite }, { "Navy", Navy }, { "OldLace", OldLace }, { "Olive", Olive }, { "OliveDrab", OliveDrab }, { "Orange", Orange }, { "OrangeRed", OrangeRed }, { "Orchid", Orchid }, { "PaleGoldenrod", PaleGoldenrod }, { "PaleGreen", PaleGreen }, { "PaleTurquoise", PaleTurquoise }, { "PaleVioletRed", PaleVioletRed }, { "PapayaWhip", PapayaWhip }, { "PeachPuff", PeachPuff }, { "Peru", Peru }, { "Pink", Pink }, { "Plum", Plum }, { "PowderBlue", PowderBlue }, { "Purple", Purple }, { "RebeccaPurple", RebeccaPurple }, { "Red", Red }, { "RosyBrown", RosyBrown }, { "RoyalBlue", RoyalBlue }, { "SaddleBrown", SaddleBrown }, { "Salmon", Salmon }, { "SandyBrown", SandyBrown }, { "SeaGreen", SeaGreen }, { "SeaShell", SeaShell }, { "Sienna", Sienna }, { "Silver", Silver }, { "SkyBlue", SkyBlue }, { "SlateBlue", SlateBlue }, { "SlateGray", SlateGray }, { "SlateGrey", SlateGrey }, { "Snow", Snow }, { "SpringGreen", SpringGreen }, { "SteelBlue", SteelBlue }, { "Tan", Tan }, { "Teal", Teal }, { "Thistle", Thistle }, { "Tomato", Tomato }, { "Transparent", Transparent }, { "Turquoise", Turquoise }, { "Violet", Violet }, { "Wheat", Wheat }, { "White", White }, { "WhiteSmoke", WhiteSmoke }, { "Yellow", Yellow }, { "YellowGreen", YellowGreen } }; } private static Color[] CreateWebSafePalette() { return new Color[142] { AliceBlue, AntiqueWhite, Aqua, Aquamarine, Azure, Beige, Bisque, Black, BlanchedAlmond, Blue, BlueViolet, Brown, BurlyWood, CadetBlue, Chartreuse, Chocolate, Coral, CornflowerBlue, Cornsilk, Crimson, Cyan, DarkBlue, DarkCyan, DarkGoldenrod, DarkGray, DarkGreen, DarkKhaki, DarkMagenta, DarkOliveGreen, DarkOrange, DarkOrchid, DarkRed, DarkSalmon, DarkSeaGreen, DarkSlateBlue, DarkSlateGray, DarkTurquoise, DarkViolet, DeepPink, DeepSkyBlue, DimGray, DodgerBlue, Firebrick, FloralWhite, ForestGreen, Fuchsia, Gainsboro, GhostWhite, Gold, Goldenrod, Gray, Green, GreenYellow, Honeydew, HotPink, IndianRed, Indigo, Ivory, Khaki, Lavender, LavenderBlush, LawnGreen, LemonChiffon, LightBlue, LightCoral, LightCyan, LightGoldenrodYellow, LightGray, LightGreen, LightPink, LightSalmon, LightSeaGreen, LightSkyBlue, LightSlateGray, LightSteelBlue, LightYellow, Lime, LimeGreen, Linen, Magenta, Maroon, MediumAquamarine, MediumBlue, MediumOrchid, MediumPurple, MediumSeaGreen, MediumSlateBlue, MediumSpringGreen, MediumTurquoise, MediumVioletRed, MidnightBlue, MintCream, MistyRose, Moccasin, NavajoWhite, Navy, OldLace, Olive, OliveDrab, Orange, OrangeRed, Orchid, PaleGoldenrod, PaleGreen, PaleTurquoise, PaleVioletRed, PapayaWhip, PeachPuff, Peru, Pink, Plum, PowderBlue, Purple, RebeccaPurple, Red, RosyBrown, RoyalBlue, SaddleBrown, Salmon, SandyBrown, SeaGreen, SeaShell, Sienna, Silver, SkyBlue, SlateBlue, SlateGray, Snow, SpringGreen, SteelBlue, Tan, Teal, Thistle, Tomato, Transparent, Turquoise, Violet, Wheat, White, WhiteSmoke, Yellow, YellowGreen }; } private static Color[] CreateWernerPalette() { return new Color[110] { ParseHex("#f1e9cd"), ParseHex("#f2e7cf"), ParseHex("#ece6d0"), ParseHex("#f2eacc"), ParseHex("#f3e9ca"), ParseHex("#f2ebcd"), ParseHex("#e6e1c9"), ParseHex("#e2ddc6"), ParseHex("#cbc8b7"), ParseHex("#bfbbb0"), ParseHex("#bebeb3"), ParseHex("#b7b5ac"), ParseHex("#bab191"), ParseHex("#9c9d9a"), ParseHex("#8a8d84"), ParseHex("#5b5c61"), ParseHex("#555152"), ParseHex("#413f44"), ParseHex("#454445"), ParseHex("#423937"), ParseHex("#433635"), ParseHex("#252024"), ParseHex("#241f20"), ParseHex("#281f3f"), ParseHex("#1c1949"), ParseHex("#4f638d"), ParseHex("#383867"), ParseHex("#5c6b8f"), ParseHex("#657abb"), ParseHex("#6f88af"), ParseHex("#7994b5"), ParseHex("#6fb5a8"), ParseHex("#719ba2"), ParseHex("#8aa1a6"), ParseHex("#d0d5d3"), ParseHex("#8590ae"), ParseHex("#3a2f52"), ParseHex("#39334a"), ParseHex("#6c6d94"), ParseHex("#584c77"), ParseHex("#533552"), ParseHex("#463759"), ParseHex("#bfbac0"), ParseHex("#77747f"), ParseHex("#4a475c"), ParseHex("#b8bfaf"), ParseHex("#b2b599"), ParseHex("#979c84"), ParseHex("#5d6161"), ParseHex("#61ac86"), ParseHex("#a4b6a7"), ParseHex("#adba98"), ParseHex("#93b778"), ParseHex("#7d8c55"), ParseHex("#33431e"), ParseHex("#7c8635"), ParseHex("#8e9849"), ParseHex("#c2c190"), ParseHex("#67765b"), ParseHex("#ab924b"), ParseHex("#c8c76f"), ParseHex("#ccc050"), ParseHex("#ebdd99"), ParseHex("#ab9649"), ParseHex("#dbc364"), ParseHex("#e6d058"), ParseHex("#ead665"), ParseHex("#d09b2c"), ParseHex("#a36629"), ParseHex("#a77d35"), ParseHex("#f0d696"), ParseHex("#d7c485"), ParseHex("#f1d28c"), ParseHex("#efcc83"), ParseHex("#f3daa7"), ParseHex("#dfa837"), ParseHex("#ebbc71"), ParseHex("#d17c3f"), ParseHex("#92462f"), ParseHex("#be7249"), ParseHex("#bb603c"), ParseHex("#c76b4a"), ParseHex("#a75536"), ParseHex("#b63e36"), ParseHex("#b5493a"), ParseHex("#cd6d57"), ParseHex("#711518"), ParseHex("#e9c49d"), ParseHex("#eedac3"), ParseHex("#eecfbf"), ParseHex("#ce536b"), ParseHex("#b74a70"), ParseHex("#b7757c"), ParseHex("#612741"), ParseHex("#7a4848"), ParseHex("#3f3033"), ParseHex("#8d746f"), ParseHex("#4d3635"), ParseHex("#6e3b31"), ParseHex("#864735"), ParseHex("#553d3a"), ParseHex("#613936"), ParseHex("#7a4b3a"), ParseHex("#946943"), ParseHex("#c39e6d"), ParseHex("#513e32"), ParseHex("#8b7859"), ParseHex("#9b856b"), ParseHex("#766051"), ParseHex("#453b32") }; } } public enum ByteOrder { BigEndian, LittleEndian } internal static class Constants { public static readonly float Epsilon = 0.001f; public static readonly float EpsilonSquared = Epsilon * Epsilon; } public class ImageFormatException : Exception { internal ImageFormatException(string errorMessage) : base(errorMessage) { } internal ImageFormatException(string errorMessage, Exception innerException) : base(errorMessage, innerException) { } } public sealed class ImageProcessingException : Exception { public ImageProcessingException() { } public ImageProcessingException(string errorMessage) : base(errorMessage) { } public ImageProcessingException(string errorMessage, Exception innerException) : base(errorMessage, innerException) { } } public sealed class InvalidImageContentException : ImageFormatException { public InvalidImageContentException(string errorMessage) : base(errorMessage) { } public InvalidImageContentException(string errorMessage, Exception innerException) : base(errorMessage, innerException) { } internal InvalidImageContentException(Size size, InvalidMemoryOperationException memoryException) : this($"Cannot decode image. Failed to allocate buffers for possibly degenerate dimensions: {size.Width}x{size.Height}.", memoryException) { } } public sealed class UnknownImageFormatException : ImageFormatException { public UnknownImageFormatException(string errorMessage) : base(errorMessage) { } } internal static class ConfigurationExtensions { public static ParallelOptions GetParallelOptions(this Configuration configuration) { return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; } } internal static class EnumerableExtensions { public static IEnumerable<int> SteppedRange(int fromInclusive, Func<int, bool> toDelegate, int step) { return RangeIterator(fromInclusive, toDelegate, step); } private static IEnumerable<int> RangeIterator(int fromInclusive, Func<int, bool> toDelegate, int step) { for (int i = fromInclusive; toDelegate(i); i += step) { yield return i; } } } internal static class StreamExtensions { public static void Write(this Stream stream, Span<byte> buffer, int offset, int count) { stream.Write(buffer.Slice(offset, count)); } public static int Read(this Stream stream, Span<byte> buffer, int offset, int count) { return stream.Read(buffer.Slice(offset, count)); } public static void Skip(this Stream stream, int count) { if (count < 1) { return; } if (stream.CanSeek) { stream.Seek(count, SeekOrigin.Current); return; } byte[] array = ArrayPool<byte>.Shared.Rent(count); try { while (count > 0) { int num = stream.Read(array, 0, count); if (num == 0) { break; } count -= num; } } finally { ArrayPool<byte>.Shared.Return(array); } } } internal static class ColorNumerics { private static readonly Vector4 Bt709 = new Vector4(0.2126f, 0.7152f, 0.0722f, 0f); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetBT709Luminance(ref Vector4 vector, int luminanceLevels) { return (int)MathF.Round(Vector4.Dot(vector, Bt709) * (float)(luminanceLevels - 1)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte Get8BitBT709Luminance(byte r, byte g, byte b) { return (byte)((float)(int)r * 0.2126f + (float)(int)g * 0.7152f + (float)(int)b * 0.0722f + 0.5f); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ushort Get16BitBT709Luminance(ushort r, ushort g, ushort b) { return (ushort)((float)(int)r * 0.2126f + (float)(int)g * 0.7152f + (float)(int)b * 0.0722f + 0.5f); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ushort Get16BitBT709Luminance(float r, float g, float b) { return (ushort)(r * 0.2126f + g * 0.7152f + b * 0.0722f + 0.5f); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte DownScaleFrom16BitTo8Bit(ushort component) { return (byte)(component * 255 + 32895 >> 16); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ushort UpscaleFrom8BitTo16Bit(byte component) { return (ushort)(component * 257); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetBitsNeededForColorDepth(int colors) { return Math.Max(1, (int)Math.Ceiling(Math.Log(colors, 2.0))); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetColorCountForBitDepth(int bitDepth) { return 1 << bitDepth; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Transform(ref Vector4 vector, ref ColorMatrix matrix) { float x = vector.X; float y = vector.Y; float z = vector.Z; float w = vector.W; vector.X = x * matrix.M11 + y * matrix.M21 + z * matrix.M31 + w * matrix.M41 + matrix.M51; vector.Y = x * matrix.M12 + y * matrix.M22 + z * matrix.M32 + w * matrix.M42 + matrix.M52; vector.Z = x * matrix.M13 + y * matrix.M23 + z * matrix.M33 + w * matrix.M43 + matrix.M53; vector.W = x * matrix.M14 + y * matrix.M24 + z * matrix.M34 + w * matrix.M44 + matrix.M54; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Transform(Span<Vector4> vectors, ref ColorMatrix matrix) { ref Vector4 reference = ref MemoryMarshal.GetReference(vectors); for (int i = 0; i < vectors.Length; i++) { Transform(ref Unsafe.Add(ref reference, i), ref matrix); } } } internal static class EnumUtils { public static TEnum Parse<TEnum>(int value, TEnum defaultValue) where TEnum : Enum { foreach (TEnum value2 in Enum.GetValues(typeof(TEnum))) { TEnum source = value2; if (value == Unsafe.As<TEnum, int>(ref source)) { return value2; } } return defaultValue; } public static bool HasFlag<TEnum>(TEnum value, TEnum flag) where TEnum : Enum { uint num = Unsafe.As<TEnum, uint>(ref flag); return (Unsafe.As<TEnum, uint>(ref value) & num) == num; } } internal static class InliningOptions { public const MethodImplOptions AlwaysInline = MethodImplOptions.AggressiveInlining; public const MethodImplOptions HotPath = MethodImplOptions.AggressiveOptimization; public const MethodImplOptions ShortMethod = MethodImplOptions.AggressiveInlining; public const MethodImplOptions ColdPath = MethodImplOptions.NoInlining; } internal static class Numerics { public const int BlendAlphaControl = 136; private const int ShuffleAlphaControl = 255; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GreatestCommonDivisor(int a, int b) { while (b != 0) { int num = b; b = a % b; a = num; } return a; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LeastCommonMultiple(int a, int b) { return a / GreatestCommonDivisor(a, b) * b; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Modulo2(int x) { return x & 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Modulo4(int x) { return x & 3; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Modulo8(int x) { return x & 7; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int ModuloP2(int x, int m) { return x & (m - 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Abs(int x) { int num = x >> 31; return (x ^ num) - num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Pow2(float x) { return x * x; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Pow3(float x) { return x * x * x; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Gaussian(float x, float sigma) { float num = MathF.Sqrt((float)Math.PI * 2f) * sigma; float num2 = (0f - x) * x; float num3 = 2f * Pow2(sigma); float num4 = 1f / num; float num5 = MathF.Exp(num2 / num3); return num4 * num5; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float SinC(float f) { if (MathF.Abs(f) > Constants.Epsilon) { f *= (float)Math.PI; float num = MathF.Sin(f) / f; if (!(MathF.Abs(num) < Constants.Epsilon)) { return num; } return 0f; } return 1f; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte Clamp(byte value, byte min, byte max) { if (value > max) { return max; } if (value < min) { return min; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint Clamp(uint value, uint min, uint max) { if (value > max) { return max; } if (value < min) { return min; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Clamp(int value, int min, int max) { if (value > max) { return max; } if (value < min) { return min; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Clamp(float value, float min, float max) { if (value > max) { return max; } if (value < min) { return min; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Clamp(double value, double min, double max) { if (value > max) { return max; } if (value < min) { return min; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Clamp(Vector4 value, Vector4 min, Vector4 max) { return Vector4.Min(Vector4.Max(value, min), max); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Clamp(Span<byte> span, byte min, byte max) { Span<byte> span2 = span.Slice(ClampReduce(span, min, max)); if (span2.Length > 0) { ref byte reference = ref MemoryMarshal.GetReference(span2); ref byte right = ref Unsafe.Add(ref reference, span2.Length); while (Unsafe.IsAddressLessThan(in reference, in right)) { reference = Clamp(reference, min, max); reference = ref Unsafe.Add(ref reference, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Clamp(Span<uint> span, uint min, uint max) { Span<uint> span2 = span.Slice(ClampReduce(span, min, max)); if (span2.Length > 0) { ref uint reference = ref MemoryMarshal.GetReference(span2); ref uint right = ref Unsafe.Add(ref reference, span2.Length); while (Unsafe.IsAddressLessThan(in reference, in right)) { reference = Clamp(reference, min, max); reference = ref Unsafe.Add(ref reference, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Clamp(Span<int> span, int min, int max) { Span<int> span2 = span.Slice(ClampReduce(span, min, max)); if (span2.Length > 0) { ref int reference = ref MemoryMarshal.GetReference(span2); ref int right = ref Unsafe.Add(ref reference, span2.Length); while (Unsafe.IsAddressLessThan(in reference, in right)) { reference = Clamp(reference, min, max); reference = ref Unsafe.Add(ref reference, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Clamp(Span<float> span, float min, float max) { Span<float> span2 = span.Slice(ClampReduce(span, min, max)); if (span2.Length > 0) { ref float reference = ref MemoryMarshal.GetReference(span2); ref float right = ref Unsafe.Add(ref reference, span2.Length); while (Unsafe.IsAddressLessThan(in reference, in right)) { reference = Clamp(reference, min, max); reference = ref Unsafe.Add(ref reference, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Clamp(Span<double> span, double min, double max) { Span<double> span2 = span.Slice(ClampReduce(span, min, max)); if (span2.Length > 0) { ref double reference = ref MemoryMarshal.GetReference(span2); ref double right = ref Unsafe.Add(ref reference, span2.Length); while (Unsafe.IsAddressLessThan(in reference, in right)) { reference = Clamp(reference, min, max); reference = ref Unsafe.Add(ref reference, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int ClampReduce<T>(Span<T> span, T min, T max) where T : unmanaged { if (Vector.IsHardwareAccelerated && span.Length >= Vector<T>.Count) { int num = ModuloP2(span.Length, Vector<T>.Count); int num2 = span.Length - num; if (num2 > 0) { ClampImpl(span.Slice(0, num2), min, max); } return num2; } return 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void ClampImpl<T>(Span<T> span, T min, T max) where T : unmanaged { MemoryMarshal.GetReference(span); Vector<T> left = new Vector<T>(min); Vector<T> right = new Vector<T>(max); int num = span.Length / Vector<T>.Count; int num2 = Modulo4(num); int elementOffset = num - num2; ref Vector<T> reference = ref Unsafe.As<T, Vector<T>>(ref MemoryMarshal.GetReference(span)); ref Vector<T> reference2 = ref Unsafe.Add(ref reference, 1); ref Vector<T> reference3 = ref Unsafe.Add(ref reference, 2); ref Vector<T> reference4 = ref Unsafe.Add(ref reference, 3); ref Vector<T> reference5 = ref Unsafe.Add(ref reference, elementOffset); while (Unsafe.IsAddressLessThan(in reference, in reference5)) { reference = Vector.Min(Vector.Max(left, reference), right); reference2 = Vector.Min(Vector.Max(left, reference2), right); reference3 = Vector.Min(Vector.Max(left, reference3), right); reference4 = Vector.Min(Vector.Max(left, reference4), right); reference = ref Unsafe.Add(ref reference, 4); reference2 = ref Unsafe.Add(ref reference2, 4); reference3 = ref Unsafe.Add(ref reference3, 4); reference4 = ref Unsafe.Add(ref reference4, 4); } if (num2 > 0) { reference = ref reference5; reference5 = ref Unsafe.Add(ref reference5, num2); while (Unsafe.IsAddressLessThan(in reference, in reference5)) { reference = Vector.Min(Vector.Max(left, reference), right); reference = ref Unsafe.Add(ref reference, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Premultiply(ref Vector4 source) { float w = source.W; source *= w; source.W = w; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void UnPremultiply(ref Vector4 source) { float w = source.W; source /= w; source.W = w; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Premultiply(Span<Vector4> vectors) { if (Avx2.IsSupported && vectors.Length >= 2) { ref Vector256<float> reference = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(vectors)); ref Vector256<float> right = ref Unsafe.Add(ref reference, (IntPtr)((uint)vectors.Length / 2u)); while (Unsafe.IsAddressLessThan(in reference, in right)) { Vector256<float> vector = reference; Vector256<float> right2 = Avx.Shuffle(vector, vector, byte.MaxValue); reference = Avx.Blend(Avx.Multiply(vector, right2), vector, 136); reference = ref Unsafe.Add(ref reference, 1); } if (Modulo2(vectors.Length) != 0) { Premultiply(ref MemoryMarshal.GetReference(vectors.Slice(vectors.Length - 1))); } } else { ref Vector4 reference2 = ref MemoryMarshal.GetReference(vectors); ref Vector4 right3 = ref Unsafe.Add(ref reference2, vectors.Length); while (Unsafe.IsAddressLessThan(in reference2, in right3)) { Premultiply(ref reference2); reference2 = ref Unsafe.Add(ref reference2, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void UnPremultiply(Span<Vector4> vectors) { if (Avx2.IsSupported && vectors.Length >= 2) { ref Vector256<float> reference = ref Unsafe.As<Vector4, Vector256<float>>(ref MemoryMarshal.GetReference(vectors)); ref Vector256<float> right = ref Unsafe.Add(ref reference, (IntPtr)((uint)vectors.Length / 2u)); while (Unsafe.IsAddressLessThan(in reference, in right)) { Vector256<float> vector = reference; Vector256<float> right2 = Avx.Shuffle(vector, vector, byte.MaxValue); reference = Avx.Blend(Avx.Divide(vector, right2), vector, 136); reference = ref Unsafe.Add(ref reference, 1); } if (Modulo2(vectors.Length) != 0) { UnPremultiply(ref MemoryMarshal.GetReference(vectors.Slice(vectors.Length - 1))); } } else { ref Vector4 reference2 = ref MemoryMarshal.GetReference(vectors); ref Vector4 right3 = ref Unsafe.Add(ref reference2, vectors.Length); while (Unsafe.IsAddressLessThan(in reference2, in right3)) { UnPremultiply(ref reference2); reference2 = ref Unsafe.Add(ref reference2, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CubePowOnXYZ(Span<Vector4> vectors) { ref Vector4 reference = ref MemoryMarshal.GetReference(vectors); ref Vector4 right = ref Unsafe.Add(ref reference, vectors.Length); while (Unsafe.IsAddressLessThan(in reference, in right)) { Vector4 vector = reference; float w = vector.W; vector = vector * vector * vector; vector.W = w; reference = vector; reference = ref Unsafe.Add(ref reference, 1); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static void CubeRootOnXYZ(Span<Vector4> vectors) { if (Sse41.IsSupported) { ref Vector128<float> reference = ref Unsafe.As<Vector4, Vector128<float>>(ref MemoryMarshal.GetReference(vectors)); ref Vector128<float> right = ref Unsafe.Add(ref reference, vectors.Length); Vector128<int> right2 = Vector128.Create(341); Vector128<int> vector = Vector128.Create(-0f).AsInt32(); Vector128<int> right3 = Vector128.Create(1f).AsInt32(); Vector128<float> left = Vector128.Create(1f / 3f); Vector128<float> vector2 = Vector128.Create(2f / 3f); while (Unsafe.IsAddressLessThan(in reference, in right)) { Vector128<float> vector3 = reference; Vector128<int> right4 = vector3.AsInt32(); right4 = Sse2.AndNot(vector, right4); right4 = Sse2.Subtract(right4, right3); right4 = Sse2.ShiftRightArithmetic(right4, 10); right4 = Sse41.MultiplyLow(right4, right2); right4 = Sse2.Add(right4, right3); right4 = Sse2.AndNot(vector, right4); right4 = Sse2.Or(right4, Sse2.And(vector3.AsInt32(), vector)); Vector128<float> vector4 = right4.AsSingle(); if (Fma.IsSupported) { vector4 = Fma.MultiplyAdd(vector2, vector4, Sse.Multiply(left, Sse.Divide(vector3, Sse.Multiply(vector4, vector4)))); vector4 = Fma.MultiplyAdd(vector2, vector4, Sse.Multiply(left, Sse.Divide(vector3, Sse.Multiply(vector4, vector4)))); } else { vector4 = Sse.Add(Sse.Multiply(vector2, vector4), Sse.Multiply(left, Sse.Divide(vector3, Sse.Multiply(vector4, vector4)))); vector4 = Sse.Add(Sse.Multiply(vector2, vector4), Sse.Multiply(left, Sse.Divide(vector3, Sse.Multiply(vector4, vector4)))); } vector4 = Sse41.Insert(vector4, vector3, 240); reference = vector4; reference = ref Unsafe.Add(ref reference, 1); } } else { ref Vector4 reference2 = ref MemoryMarshal.GetReference(vectors); ref Vector4 right5 = ref Unsafe.Add(ref reference2, vectors.Length); Vector4 vector6 = default(Vector4); while (Unsafe.IsAddressLessThan(in reference2, in right5)) { Vector4 vector5 = reference2; double num = vector5.X; double num2 = vector5.Y; double num3 = vector5.Z; float w = vector5.W; ulong num4 = *(ulong*)(&num); ulong num5 = *(ulong*)(&num2); ulong num6 = *(ulong*)(&num3); num4 = 3071325735593686528L + num4 / 3; num5 = 3071325735593686528L + num5 / 3; num6 = 3071325735593686528L + num6 / 3; vector6.X = (float)(*(double*)(&num4)); vector6.Y = (float)(*(double*)(&num5)); vector6.Z = (float)(*(double*)(&num6)); vector6.W = 0f; vector6 = 2f / 3f * vector6 + 1f / 3f * (vector5 / (vector6 * vector6)); vector6 = 2f / 3f * vector6 + 1f / 3f * (vector5 / (vector6 * vector6)); vector6.W = w; reference2 = vector6; reference2 = ref Unsafe.Add(ref reference2, 1); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector256<float> Lerp(in Vector256<float> value1, in Vector256<float> value2, in Vector256<float> amount) { Vector256<float> vector = Avx.Subtract(value2, value1); if (Fma.IsSupported) { return Fma.MultiplyAdd(vector, amount, value1); } return Avx.Add(Avx.Multiply(vector, amount), value1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Lerp(float value1, float value2, float amount) { return (value2 - value1) * amount + value1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Accumulate(ref Vector<uint> accumulator, Vector<byte> values) { Vector.Widen(values, out var low, out var high); Vector.Widen(low, out var low2, out var high2); accumulator += low2; accumulator += high2; Vector.Widen(high, out low2, out high2); accumulator += low2; accumulator += high2; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int ReduceSum(Vector128<int> accumulator) { if (Ssse3.IsSupported) { Vector128<int> vector = Ssse3.HorizontalAdd(accumulator, accumulator); Vector128<int> right = Sse2.Shuffle(vector, 1); return Sse2.ConvertToInt32(Sse2.Add(vector, right)); } int num = 0; for (int i = 0; i < Vector128<int>.Count; i++) { num += accumulator.GetElement(i); } return num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int ReduceSum(Vector256<int> accumulator) { Vector128<int> vector = Sse2.Add(accumulator.GetLower(), accumulator.GetUpper()); Vector128<int> vector2 = Sse2.Add(vector, Sse2.Shuffle(vector, 245)); return Sse2.ConvertToInt32(Sse2.Add(vector2, Sse2.Shuffle(vector2, 238))); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int EvenReduceSum(Vector256<int> accumulator) { Vector128<int> vector = Sse2.Add(accumulator.GetLower(), accumulator.GetUpper()); return Sse2.ConvertToInt32(Sse2.Add(vector, Sse2.Shuffle(vector, 238))); } public static int Log2(uint value) { return BitOperations.Log2(value); } public static uint DivideCeil(uint value, uint divisor) { return (value + divisor - 1) / divisor; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint RotateLeft(uint value, int offset) { return BitOperations.RotateLeft(value, offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint RotateRight(uint value, int offset) { return BitOperations.RotateRight(value, offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOutOfRange(int value, int min, int max) { return (uint)(value - min) > (uint)(max - min); } } internal static class RuntimeEnvironment { private static readonly Lazy<bool> IsNetCoreLazy = new Lazy<bool>(() => FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase)); public static bool IsNetCore => IsNetCoreLazy.Value; public static string FrameworkDescription => RuntimeInformation.FrameworkDescription; public static bool IsOSPlatform(OSPlatform osPlatform) { return RuntimeInformation.IsOSPlatform(osPlatform); } } internal interface IComponentShuffle { byte Control { get; } void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest); } internal interface IShuffle4 : IComponentShuffle { } internal readonly struct DefaultShuffle4 : IShuffle4, IComponentShuffle { private readonly byte p3; private readonly byte p2; private readonly byte p1; private readonly byte p0; public byte Control { get; } public DefaultShuffle4(byte p3, byte p2, byte p1, byte p0) { this.p3 = p3; this.p2 = p2; this.p1 = p1; this.p0 = p0; Control = SimdUtils.Shuffle.MmShuffle(p3, p2, p1, p0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest) { ref byte reference = ref MemoryMarshal.GetReference(source); ref byte reference2 = ref MemoryMarshal.GetReference(dest); int num = p3; int num2 = p2; int num3 = p1; int num4 = p0; for (int i = 0; i < source.Length; i += 4) { Unsafe.Add(ref reference2, i) = Unsafe.Add(ref reference, num4 + i); Unsafe.Add(ref reference2, i + 1) = Unsafe.Add(ref reference, num3 + i); Unsafe.Add(ref reference2, i + 2) = Unsafe.Add(ref reference, num2 + i); Unsafe.Add(ref reference2, i + 3) = Unsafe.Add(ref reference, num + i); } } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal readonly struct WXYZShuffle4 : IShuffle4, IComponentShuffle { public byte Control { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return SimdUtils.Shuffle.MmShuffle(2, 1, 0, 3); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest) { ref uint source2 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(source)); ref uint source3 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest)); int num = source.Length / 4; for (int i = 0; i < num; i++) { uint num2 = Unsafe.Add(ref source2, i); Unsafe.Add(ref source3, i) = (num2 << 8) | (num2 >> 24); } } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal readonly struct WZYXShuffle4 : IShuffle4, IComponentShuffle { public byte Control { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return SimdUtils.Shuffle.MmShuffle(0, 1, 2, 3); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest) { ref uint source2 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(source)); ref uint source3 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest)); int num = source.Length / 4; for (int i = 0; i < num; i++) { uint value = Unsafe.Add(ref source2, i); Unsafe.Add(ref source3, i) = BinaryPrimitives.ReverseEndianness(value); } } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal readonly struct YZWXShuffle4 : IShuffle4, IComponentShuffle { public byte Control { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return SimdUtils.Shuffle.MmShuffle(0, 3, 2, 1); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest) { ref uint source2 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(source)); ref uint source3 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest)); int num = source.Length / 4; for (int i = 0; i < num; i++) { uint value = Unsafe.Add(ref source2, i); Unsafe.Add(ref source3, i) = Numerics.RotateRight(value, 8); } } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal readonly struct ZYXWShuffle4 : IShuffle4, IComponentShuffle { public byte Control { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return SimdUtils.Shuffle.MmShuffle(3, 0, 1, 2); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest) { ref uint source2 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(source)); ref uint source3 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest)); int num = source.Length / 4; for (int i = 0; i < num; i++) { uint num2 = Unsafe.Add(ref source2, i); uint num3 = num2 & 0xFF00FF00u; uint num4 = Numerics.RotateLeft(num2 & 0xFF00FF, 16); Unsafe.Add(ref source3, i) = num3 + num4; } } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal readonly struct XWZYShuffle4 : IShuffle4, IComponentShuffle { public byte Control { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return SimdUtils.Shuffle.MmShuffle(1, 2, 3, 0); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest) { ref uint source2 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(source)); ref uint source3 = ref Unsafe.As<byte, uint>(ref MemoryMarshal.GetReference(dest)); int num = source.Length / 4; for (int i = 0; i < num; i++) { uint num2 = Unsafe.Add(ref source2, i); uint num3 = num2 & 0xFF00FF; uint num4 = Numerics.RotateLeft(num2 & 0xFF00FF00u, 16); Unsafe.Add(ref source3, i) = num3 + num4; } } } internal interface IPad3Shuffle4 : IComponentShuffle { } internal readonly struct DefaultPad3Shuffle4 : IPad3Shuffle4, IComponentShuffle { private readonly byte p3; private readonly byte p2; private readonly byte p1; private readonly byte p0; public byte Control { get; } public DefaultPad3Shuffle4(byte p3, byte p2, byte p1, byte p0) { this.p3 = p3; this.p2 = p2; this.p1 = p1; this.p0 = p0; Control = SimdUtils.Shuffle.MmShuffle(p3, p2, p1, p0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest) { ref byte reference = ref MemoryMarshal.GetReference(source); ref byte reference2 = ref MemoryMarshal.GetReference(dest); int elementOffset = p3; int elementOffset2 = p2; int elementOffset3 = p1; int elementOffset4 = p0; ref byte reference3 = ref MemoryMarshal.GetReference(stackalloc byte[4]); ref uint reference4 = ref Unsafe.As<byte, uint>(ref reference3); int num = 0; int num2 = 0; while (num < source.Length) { reference4 = Unsafe.As<byte, uint>(ref Unsafe.Add(ref reference, num)) | 0xFF000000u; Unsafe.Add(ref reference2, num2) = Unsafe.Add(ref reference3, elementOffset4); Unsafe.Add(ref reference2, num2 + 1) = Unsafe.Add(ref reference3, elementOffset3); Unsafe.Add(ref reference2, num2 + 2) = Unsafe.Add(ref reference3, elementOffset2); Unsafe.Add(ref reference2, num2 + 3) = Unsafe.Add(ref reference3, elementOffset); num += 3; num2 += 4; } } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal readonly struct XYZWPad3Shuffle4 : IPad3Shuffle4, IComponentShuffle { public byte Control { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return SimdUtils.Shuffle.MmShuffle(3, 2, 1, 0); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest) { ref byte reference = ref MemoryMarshal.GetReference(source); ref byte source2 = ref MemoryMarshal.GetReference(dest); ref byte reference2 = ref Unsafe.Add(ref reference, source.Length); ref byte right = ref Unsafe.Subtract(ref reference2, 4); while (Unsafe.IsAddressLessThan(in reference, in right)) { Unsafe.As<byte, uint>(ref source2) = Unsafe.As<byte, uint>(ref reference) |