Fixed sampling not scaling with DPI. Also disabled implicit usings which is most of this commit.

This commit is contained in:
That_One_Nerd 2024-03-19 08:57:02 -04:00
parent c30ced7578
commit 762a5f5a32
25 changed files with 79 additions and 17 deletions

View File

@ -5,7 +5,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>Graphing</RootNamespace>
<AssemblyName>ThatOneNerd.Graphing</AssemblyName>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>

View File

@ -20,4 +20,9 @@
<SubType>Form</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Forms\ViewCacheForm.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -1,4 +1,6 @@
namespace Graphing;
using System.Drawing;
namespace Graphing;
public record struct Float2
{

View File

@ -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);

View File

@ -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;

View File

@ -1,4 +1,7 @@
namespace Graphing.Forms
using System.Drawing;
using System.Windows.Forms;
namespace Graphing.Forms
{
partial class GraphColorPickerForm
{

View File

@ -1,4 +1,8 @@
namespace Graphing.Forms;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Graphing.Forms;
public partial class GraphColorPickerForm : Form
{

View File

@ -1,4 +1,7 @@
namespace Graphing.Forms
using System.Drawing;
using System.Windows.Forms;
namespace Graphing.Forms
{
partial class GraphForm
{

View File

@ -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;

View File

@ -1,4 +1,7 @@
namespace Graphing.Forms
using System.Drawing;
using System.Windows.Forms;
namespace Graphing.Forms
{
partial class SetZoomForm
{

View File

@ -1,4 +1,7 @@
namespace Graphing.Forms;
using System;
using System.Windows.Forms;
namespace Graphing.Forms;
public partial class SetZoomForm : Form
{

View File

@ -1,4 +1,7 @@
namespace Graphing.Forms
using System.Drawing;
using System.Windows.Forms;
namespace Graphing.Forms
{
partial class ViewCacheForm
{

View File

@ -1,4 +1,8 @@
using Graphing.Extensions;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Graphing.Forms;

View File

@ -1,4 +1,6 @@
using Graphing.Forms;
using System.Collections.Generic;
using System.Drawing;
namespace Graphing;

View File

@ -1,5 +1,8 @@
using Graphing.Forms;
using Graphing.Parts;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Graphing.Graphables;

View File

@ -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<IGraphPart> 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<IGraphPart> 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);

View File

@ -1,5 +1,7 @@
using Graphing.Forms;
using Graphing.Parts;
using System;
using System.Collections.Generic;
namespace Graphing.Graphables;

View File

@ -1,5 +1,7 @@
using Graphing.Forms;
using Graphing.Parts;
using System;
using System.Collections.Generic;
namespace Graphing.Graphables;

View File

@ -1,4 +1,5 @@
using Graphing.Forms;
using System.Drawing;
namespace Graphing;

View File

@ -1,4 +1,6 @@
namespace Graphing;
using System.Drawing;
namespace Graphing;
public record struct Int2
{

View File

@ -1,4 +1,5 @@
using Graphing.Forms;
using System.Drawing;
namespace Graphing.Parts;

View File

@ -1,4 +1,5 @@
using Graphing.Forms;
using System.Drawing;
namespace Graphing.Parts;

View File

@ -1,4 +1,5 @@
using Graphing.Forms;
using System.Drawing;
namespace Graphing.Parts;

View File

@ -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

View File

@ -4,7 +4,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>Graphing.Testing</RootNamespace>
<AssemblyName>ThatOneNerd.Graphing.Testing</AssemblyName>
</PropertyGroup>