diff options
| author | a1xd <[email protected]> | 2021-09-23 18:40:52 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-09-23 18:40:52 -0400 |
| commit | 6d63eee26296f94a0ebd90a5686c03b256890e1f (patch) | |
| tree | 64265a352527dee794c70a3b2f3f1c5dc310daaa | |
| parent | make last move dot larger (diff) | |
| download | rawaccel-6d63eee26296f94a0ebd90a5686c03b256890e1f.tar.xz rawaccel-6d63eee26296f94a0ebd90a5686c03b256890e1f.zip | |
check number of points on LUT parse
| -rw-r--r-- | grapher/Models/Options/LUT/LUTPanelOptions.cs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/grapher/Models/Options/LUT/LUTPanelOptions.cs b/grapher/Models/Options/LUT/LUTPanelOptions.cs index 4357619..3690c76 100644 --- a/grapher/Models/Options/LUT/LUTPanelOptions.cs +++ b/grapher/Models/Options/LUT/LUTPanelOptions.cs @@ -135,17 +135,31 @@ namespace grapher.Models.Options.LUT private static (Vec2<float>[], int length) UserTextToPoints(string userText) { + const int MaxPoints = 256; + if (string.IsNullOrWhiteSpace(userText)) { throw new ApplicationException("Text must be entered in text box to fill Look Up Table."); } - Vec2<float>[] points = new Vec2<float>[256]; + Vec2<float>[] points = new Vec2<float>[MaxPoints]; var userTextSplit = userText.Trim().Trim(';').Split(';'); int index = 0; float lastX = 0; + int pointsCount = userTextSplit.Count(); + + if (pointsCount < 2) + { + throw new ApplicationException("At least 2 points required"); + } + + if (pointsCount > MaxPoints) + { + throw new ApplicationException($"Number of points exceeds max ({MaxPoints})"); + } + foreach(var pointEntry in userTextSplit) { var pointSplit = pointEntry.Trim().Split(','); |