From 762a5f5a32ff855961b472b3fb4bf23d42c1bb84 Mon Sep 17 00:00:00 2001 From: That_One_Nerd Date: Tue, 19 Mar 2024 08:57:02 -0400 Subject: [PATCH] Fixed sampling not scaling with DPI. Also disabled implicit usings which is most of this commit. --- Base/Base.csproj | 2 +- Base/Base.csproj.user | 5 +++++ Base/Float2.cs | 4 +++- Base/Forms/Controls/PieChart.Designer.cs | 6 ++++-- Base/Forms/Controls/PieChart.cs | 6 +++++- Base/Forms/GraphColorPickerForm.Designer.cs | 5 ++++- Base/Forms/GraphColorPickerForm.cs | 6 +++++- Base/Forms/GraphForm.Designer.cs | 5 ++++- Base/Forms/GraphForm.cs | 5 +++++ Base/Forms/SetZoomForm.Designer.cs | 5 ++++- Base/Forms/SetZoomForm.cs | 5 ++++- Base/Forms/ViewCacheForm.Designer.cs | 5 ++++- Base/Forms/ViewCacheForm.cs | 4 ++++ Base/Graphable.cs | 2 ++ Base/Graphables/ColumnTable.cs | 3 +++ Base/Graphables/Equation.cs | 6 +++++- Base/Graphables/SlopeField.cs | 2 ++ Base/Graphables/TangentLine.cs | 2 ++ Base/IGraphPart.cs | 1 + Base/Int2.cs | 4 +++- Base/Parts/GraphLine.cs | 1 + Base/Parts/GraphRectangle.cs | 1 + Base/Parts/GraphUiCircle.cs | 1 + Testing/Program.cs | 8 +++++--- Testing/Testing.csproj | 2 +- 25 files changed, 79 insertions(+), 17 deletions(-) diff --git a/Base/Base.csproj b/Base/Base.csproj index a26f79f..63d9cae 100644 --- a/Base/Base.csproj +++ b/Base/Base.csproj @@ -5,7 +5,7 @@ net8.0-windows enable true - enable + disable Graphing ThatOneNerd.Graphing True diff --git a/Base/Base.csproj.user b/Base/Base.csproj.user index 4bb9e32..ef577eb 100644 --- a/Base/Base.csproj.user +++ b/Base/Base.csproj.user @@ -20,4 +20,9 @@ Form + + + Designer + + \ No newline at end of file diff --git a/Base/Float2.cs b/Base/Float2.cs index 07005bc..cabb225 100644 --- a/Base/Float2.cs +++ b/Base/Float2.cs @@ -1,4 +1,6 @@ -namespace Graphing; +using System.Drawing; + +namespace Graphing; public record struct Float2 { diff --git a/Base/Forms/Controls/PieChart.Designer.cs b/Base/Forms/Controls/PieChart.Designer.cs index 18b52e0..ccf2086 100644 --- a/Base/Forms/Controls/PieChart.Designer.cs +++ b/Base/Forms/Controls/PieChart.Designer.cs @@ -1,4 +1,6 @@ -namespace Graphing.Forms.Controls +using System.Drawing; + +namespace Graphing.Forms.Controls { partial class PieChart { @@ -33,7 +35,7 @@ // PieChart // AutoScaleDimensions = new SizeF(13F, 32F); - AutoScaleMode = AutoScaleMode.Font; + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; Name = "PieChart"; Size = new Size(500, 500); ResumeLayout(false); diff --git a/Base/Forms/Controls/PieChart.cs b/Base/Forms/Controls/PieChart.cs index 2cb05f0..3245320 100644 --- a/Base/Forms/Controls/PieChart.cs +++ b/Base/Forms/Controls/PieChart.cs @@ -1,4 +1,8 @@ -using System.Drawing.Drawing2D; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; namespace Graphing.Forms.Controls; diff --git a/Base/Forms/GraphColorPickerForm.Designer.cs b/Base/Forms/GraphColorPickerForm.Designer.cs index f50ae6c..8b708a4 100644 --- a/Base/Forms/GraphColorPickerForm.Designer.cs +++ b/Base/Forms/GraphColorPickerForm.Designer.cs @@ -1,4 +1,7 @@ -namespace Graphing.Forms +using System.Drawing; +using System.Windows.Forms; + +namespace Graphing.Forms { partial class GraphColorPickerForm { diff --git a/Base/Forms/GraphColorPickerForm.cs b/Base/Forms/GraphColorPickerForm.cs index 98147cb..42afe02 100644 --- a/Base/Forms/GraphColorPickerForm.cs +++ b/Base/Forms/GraphColorPickerForm.cs @@ -1,4 +1,8 @@ -namespace Graphing.Forms; +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace Graphing.Forms; public partial class GraphColorPickerForm : Form { diff --git a/Base/Forms/GraphForm.Designer.cs b/Base/Forms/GraphForm.Designer.cs index 4bb2c83..f30584b 100644 --- a/Base/Forms/GraphForm.Designer.cs +++ b/Base/Forms/GraphForm.Designer.cs @@ -1,4 +1,7 @@ -namespace Graphing.Forms +using System.Drawing; +using System.Windows.Forms; + +namespace Graphing.Forms { partial class GraphForm { diff --git a/Base/Forms/GraphForm.cs b/Base/Forms/GraphForm.cs index 5909cfe..4d13472 100644 --- a/Base/Forms/GraphForm.cs +++ b/Base/Forms/GraphForm.cs @@ -1,6 +1,11 @@ using Graphing.Graphables; using Graphing.Parts; +using System; +using System.Collections.Generic; +using System.Drawing; using System.Drawing.Drawing2D; +using System.Linq; +using System.Windows.Forms; namespace Graphing.Forms; diff --git a/Base/Forms/SetZoomForm.Designer.cs b/Base/Forms/SetZoomForm.Designer.cs index e659456..52990db 100644 --- a/Base/Forms/SetZoomForm.Designer.cs +++ b/Base/Forms/SetZoomForm.Designer.cs @@ -1,4 +1,7 @@ -namespace Graphing.Forms +using System.Drawing; +using System.Windows.Forms; + +namespace Graphing.Forms { partial class SetZoomForm { diff --git a/Base/Forms/SetZoomForm.cs b/Base/Forms/SetZoomForm.cs index 1d30ee4..fc21296 100644 --- a/Base/Forms/SetZoomForm.cs +++ b/Base/Forms/SetZoomForm.cs @@ -1,4 +1,7 @@ -namespace Graphing.Forms; +using System; +using System.Windows.Forms; + +namespace Graphing.Forms; public partial class SetZoomForm : Form { diff --git a/Base/Forms/ViewCacheForm.Designer.cs b/Base/Forms/ViewCacheForm.Designer.cs index c847e6b..e2d9498 100644 --- a/Base/Forms/ViewCacheForm.Designer.cs +++ b/Base/Forms/ViewCacheForm.Designer.cs @@ -1,4 +1,7 @@ -namespace Graphing.Forms +using System.Drawing; +using System.Windows.Forms; + +namespace Graphing.Forms { partial class ViewCacheForm { diff --git a/Base/Forms/ViewCacheForm.cs b/Base/Forms/ViewCacheForm.cs index 72be698..7f767a9 100644 --- a/Base/Forms/ViewCacheForm.cs +++ b/Base/Forms/ViewCacheForm.cs @@ -1,4 +1,8 @@ using Graphing.Extensions; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; namespace Graphing.Forms; diff --git a/Base/Graphable.cs b/Base/Graphable.cs index 83e3666..2844ef7 100644 --- a/Base/Graphable.cs +++ b/Base/Graphable.cs @@ -1,4 +1,6 @@ using Graphing.Forms; +using System.Collections.Generic; +using System.Drawing; namespace Graphing; diff --git a/Base/Graphables/ColumnTable.cs b/Base/Graphables/ColumnTable.cs index b438b62..0461cc3 100644 --- a/Base/Graphables/ColumnTable.cs +++ b/Base/Graphables/ColumnTable.cs @@ -1,5 +1,8 @@ using Graphing.Forms; using Graphing.Parts; +using System; +using System.Collections.Generic; +using System.Linq; namespace Graphing.Graphables; diff --git a/Base/Graphables/Equation.cs b/Base/Graphables/Equation.cs index a2cb3ef..50864f1 100644 --- a/Base/Graphables/Equation.cs +++ b/Base/Graphables/Equation.cs @@ -1,5 +1,7 @@ using Graphing.Forms; using Graphing.Parts; +using System; +using System.Collections.Generic; namespace Graphing.Graphables; @@ -22,15 +24,17 @@ public class Equation : Graphable public override IEnumerable GetItemsToRender(in GraphForm graph) { const int step = 10; + double epsilon = Math.Abs(graph.ScreenSpaceToGraphSpace(new Int2(0, 0)).x - graph.ScreenSpaceToGraphSpace(new Int2(step / 2, 0)).x) / 5; + epsilon *= graph.DpiFloat / 192; List lines = []; double previousX = graph.MinVisibleGraph.x; double previousY = GetFromCache(previousX, epsilon); - for (int i = 1; i < graph.ClientRectangle.Width; i += step) + for (int i = 0; i < graph.ClientRectangle.Width + step; i += step) { double currentX = graph.ScreenSpaceToGraphSpace(new Int2(i, 0)).x; double currentY = GetFromCache(currentX, epsilon); diff --git a/Base/Graphables/SlopeField.cs b/Base/Graphables/SlopeField.cs index 858d2a9..066f658 100644 --- a/Base/Graphables/SlopeField.cs +++ b/Base/Graphables/SlopeField.cs @@ -1,5 +1,7 @@ using Graphing.Forms; using Graphing.Parts; +using System; +using System.Collections.Generic; namespace Graphing.Graphables; diff --git a/Base/Graphables/TangentLine.cs b/Base/Graphables/TangentLine.cs index f32c460..f22eec0 100644 --- a/Base/Graphables/TangentLine.cs +++ b/Base/Graphables/TangentLine.cs @@ -1,5 +1,7 @@ using Graphing.Forms; using Graphing.Parts; +using System; +using System.Collections.Generic; namespace Graphing.Graphables; diff --git a/Base/IGraphPart.cs b/Base/IGraphPart.cs index 083ef85..fb4ad53 100644 --- a/Base/IGraphPart.cs +++ b/Base/IGraphPart.cs @@ -1,4 +1,5 @@ using Graphing.Forms; +using System.Drawing; namespace Graphing; diff --git a/Base/Int2.cs b/Base/Int2.cs index 6377498..92dfd18 100644 --- a/Base/Int2.cs +++ b/Base/Int2.cs @@ -1,4 +1,6 @@ -namespace Graphing; +using System.Drawing; + +namespace Graphing; public record struct Int2 { diff --git a/Base/Parts/GraphLine.cs b/Base/Parts/GraphLine.cs index 7c042e1..3b7527b 100644 --- a/Base/Parts/GraphLine.cs +++ b/Base/Parts/GraphLine.cs @@ -1,4 +1,5 @@ using Graphing.Forms; +using System.Drawing; namespace Graphing.Parts; diff --git a/Base/Parts/GraphRectangle.cs b/Base/Parts/GraphRectangle.cs index 54b23fc..4881397 100644 --- a/Base/Parts/GraphRectangle.cs +++ b/Base/Parts/GraphRectangle.cs @@ -1,4 +1,5 @@ using Graphing.Forms; +using System.Drawing; namespace Graphing.Parts; diff --git a/Base/Parts/GraphUiCircle.cs b/Base/Parts/GraphUiCircle.cs index fc3be63..7f46411 100644 --- a/Base/Parts/GraphUiCircle.cs +++ b/Base/Parts/GraphUiCircle.cs @@ -1,4 +1,5 @@ using Graphing.Forms; +using System.Drawing; namespace Graphing.Parts; diff --git a/Testing/Program.cs b/Testing/Program.cs index 4770ac6..d0253c6 100644 --- a/Testing/Program.cs +++ b/Testing/Program.cs @@ -1,5 +1,7 @@ using Graphing.Forms; using Graphing.Graphables; +using System; +using System.Windows.Forms; namespace Graphing.Testing; @@ -14,10 +16,10 @@ internal static class Program GraphForm graph = new("One Of The Graphing Calculators Of All Time"); - Equation possibleA = new(Math.Sin); + Equation equ = new(x => Math.Sin(x)); SlopeField sf = new(2, (x, y) => Math.Cos(x)); - TangentLine tl = new(2, 2, possibleA); - graph.Graph(possibleA, sf, tl); + TangentLine tl = new(2, 2, equ); + graph.Graph(equ, sf, tl); // You can preload graphs in by going Misc > Preload Cache. // Keep in mind this uses more memory than usual and can take diff --git a/Testing/Testing.csproj b/Testing/Testing.csproj index fe3e2f2..6d21d69 100644 --- a/Testing/Testing.csproj +++ b/Testing/Testing.csproj @@ -4,7 +4,7 @@ net8.0-windows enable true - enable + disable Graphing.Testing ThatOneNerd.Graphing.Testing