Replaced DpiFloat with ScalingFactor
This commit is contained in:
parent
a780e58378
commit
3ed0f80454
@ -41,7 +41,7 @@ public partial class GraphColorPickerForm : Form
|
||||
MessageLabel.Text = $"Pick a color for {able.Name}.";
|
||||
|
||||
// Add preset buttons.
|
||||
int size = (int)(graph.DpiFloat * 48 / 192);
|
||||
int size = (int)(graph.ScalingFactor * 48);
|
||||
int position = 0;
|
||||
foreach (uint cId in Graphable.DefaultColors)
|
||||
{
|
||||
|
||||
@ -29,7 +29,7 @@ public partial class GraphForm : Form
|
||||
public Float2 ScreenCenter { get; set; }
|
||||
public Float2 Dpi { get; private set; }
|
||||
|
||||
public float DpiFloat { get; private set; }
|
||||
public float ScalingFactor { get; private set; }
|
||||
|
||||
public Float2 ZoomLevel
|
||||
{
|
||||
@ -92,7 +92,7 @@ public partial class GraphForm : Form
|
||||
Dpi = new(tempG.DpiX, tempG.DpiY);
|
||||
tempG.Dispose();
|
||||
|
||||
DpiFloat = (float)((Dpi.x + Dpi.y) / 2);
|
||||
ScalingFactor = (float)((Dpi.x + Dpi.y) / 384.0);
|
||||
|
||||
ables = [];
|
||||
ZoomLevel = new(1, 1);
|
||||
@ -142,7 +142,7 @@ public partial class GraphForm : Form
|
||||
|
||||
// Draw horizontal/vertical quarter-axis.
|
||||
Brush quarterBrush = new SolidBrush(QuarterAxisColor);
|
||||
Pen quarterPen = new(quarterBrush, DpiFloat * 2 / 192);
|
||||
Pen quarterPen = new(quarterBrush, ScalingFactor * 2);
|
||||
|
||||
for (double x = Math.Ceiling(MinVisibleGraph.x * 4 / axisScaleX) * axisScaleX / 4; x <= Math.Floor(MaxVisibleGraph.x * 4 / axisScaleX) * axisScaleX / 4; x += axisScaleX / 4)
|
||||
{
|
||||
@ -159,7 +159,7 @@ public partial class GraphForm : Form
|
||||
|
||||
// Draw horizontal/vertical semi-axis.
|
||||
Brush semiBrush = new SolidBrush(SemiAxisColor);
|
||||
Pen semiPen = new(semiBrush, DpiFloat * 2 / 192);
|
||||
Pen semiPen = new(semiBrush, ScalingFactor * 2);
|
||||
|
||||
for (double x = Math.Ceiling(MinVisibleGraph.x / axisScaleX) * axisScaleX; x <= Math.Floor(MaxVisibleGraph.x / axisScaleX) * axisScaleX; x += axisScaleX)
|
||||
{
|
||||
@ -175,7 +175,7 @@ public partial class GraphForm : Form
|
||||
}
|
||||
|
||||
Brush mainLineBrush = new SolidBrush(MainAxisColor);
|
||||
Pen mainLinePen = new(mainLineBrush, DpiFloat * 3 / 192);
|
||||
Pen mainLinePen = new(mainLineBrush, ScalingFactor * 3);
|
||||
|
||||
// Draw the main axis (on top of the semi axis).
|
||||
Int2 startCenterY = GraphSpaceToScreenSpace(new Float2(0, MinVisibleGraph.y)),
|
||||
@ -194,8 +194,8 @@ public partial class GraphForm : Form
|
||||
Font textFont = new(Font.Name, 9, FontStyle.Regular);
|
||||
|
||||
// X-axis
|
||||
int minX = (int)(DpiFloat * 50 / 192),
|
||||
maxX = ClientRectangle.Height - (int)(DpiFloat * 40 / 192);
|
||||
int minX = (int)(ScalingFactor * 50),
|
||||
maxX = ClientRectangle.Height - (int)(ScalingFactor * 40);
|
||||
for (double x = Math.Ceiling(MinVisibleGraph.x / axisScaleX) * axisScaleX; x <= MaxVisibleGraph.x; x += axisScaleX)
|
||||
{
|
||||
if (x == 0) x = 0; // Fixes -0
|
||||
@ -209,7 +209,7 @@ public partial class GraphForm : Form
|
||||
}
|
||||
|
||||
// Y-axis
|
||||
int minY = (int)(DpiFloat * 10 / 192);
|
||||
int minY = (int)(ScalingFactor * 10);
|
||||
for (double y = Math.Ceiling(MinVisibleGraph.y / axisScaleY) * axisScaleY; y <= MaxVisibleGraph.y; y += axisScaleY)
|
||||
{
|
||||
if (y == 0) continue;
|
||||
@ -217,7 +217,7 @@ public partial class GraphForm : Form
|
||||
Int2 screenPos = GraphSpaceToScreenSpace(new Float2(0, y));
|
||||
|
||||
string result = y.ToString();
|
||||
int maxY = ClientRectangle.Width - (int)(DpiFloat * (textFont.Height * result.Length * 0.40 + 15) / 192);
|
||||
int maxY = ClientRectangle.Width - (int)(ScalingFactor * (textFont.Height * result.Length * 0.40 + 15));
|
||||
|
||||
if (screenPos.x < minY) screenPos.x = minY;
|
||||
else if (screenPos.x > maxY) screenPos.x = maxY;
|
||||
@ -247,7 +247,7 @@ public partial class GraphForm : Form
|
||||
{
|
||||
IEnumerable<IGraphPart> lines = ables[i].GetItemsToRender(this);
|
||||
Brush graphBrush = new SolidBrush(ables[i].Color);
|
||||
Pen graphPen = new(graphBrush, DpiFloat * 3 / 192);
|
||||
Pen graphPen = new(graphBrush, ScalingFactor * 3);
|
||||
graphPens[i] = graphPen;
|
||||
foreach (IGraphPart gp in lines) gp.Render(this, g, graphPen);
|
||||
}
|
||||
@ -274,7 +274,7 @@ public partial class GraphForm : Form
|
||||
if (boxPosA.x > boxPosB.x) (boxPosA.x, boxPosB.x) = (boxPosB.x, boxPosA.x);
|
||||
if (boxPosA.y > boxPosB.y) (boxPosA.y, boxPosB.y) = (boxPosB.y, boxPosA.y);
|
||||
|
||||
Pen boxPen = new(ZoomBoxColor, 2 * DpiFloat / 192);
|
||||
Pen boxPen = new(ZoomBoxColor, ScalingFactor * 2);
|
||||
g.DrawRectangle(boxPen, new(boxPosA.x, boxPosA.y,
|
||||
boxPosB.x - boxPosA.x,
|
||||
boxPosB.y - boxPosA.y));
|
||||
|
||||
@ -37,9 +37,9 @@ public partial class ViewCacheForm : Form
|
||||
CachePie.Values.Add((able.Color, thisBytes));
|
||||
totalBytes += thisBytes;
|
||||
|
||||
int buttonHeight = (int)(refForm.DpiFloat * 46 / 192),
|
||||
buttonWidth = (int)(refForm.DpiFloat * 92 / 192),
|
||||
buttonSpaced = (int)(refForm.DpiFloat * 98 / 192);
|
||||
int buttonHeight = (int)(refForm.ScalingFactor * 46),
|
||||
buttonWidth = (int)(refForm.ScalingFactor * 92),
|
||||
buttonSpaced = (int)(refForm.ScalingFactor * 98);
|
||||
|
||||
if (index < labelCache.Count)
|
||||
{
|
||||
|
||||
@ -91,7 +91,7 @@ public class ColumnTable : Graphable
|
||||
}
|
||||
|
||||
int totalDist = (int)Math.Sqrt(distX * distX + distY * distY);
|
||||
return totalDist < 50 * factor * graph.DpiFloat / 192;
|
||||
return totalDist < 50 * factor * graph.ScalingFactor;
|
||||
}
|
||||
public override IEnumerable<IGraphPart> GetSelectionItemsToRender(in GraphForm graph, Float2 graphMousePos)
|
||||
{
|
||||
|
||||
@ -43,7 +43,7 @@ public class Equation : Graphable, IIntegrable, IDerivable, ITranslatableXY, ICo
|
||||
|
||||
double epsilon = Math.Abs(graph.ScreenSpaceToGraphSpace(new Int2(0, 0)).x
|
||||
- graph.ScreenSpaceToGraphSpace(new Int2(step / 2, 0)).x) / 5;
|
||||
epsilon *= graph.DpiFloat / 192;
|
||||
epsilon *= graph.ScalingFactor;
|
||||
|
||||
List<IGraphPart> lines = [];
|
||||
|
||||
@ -142,7 +142,7 @@ public class Equation : Graphable, IIntegrable, IDerivable, ITranslatableXY, ICo
|
||||
(_, _, int index) = NearestCachedPoint(graphMousePos.x);
|
||||
Int2 screenCachePos = graph.GraphSpaceToScreenSpace(cache[index]);
|
||||
|
||||
double allowedDist = factor * graph.DpiFloat * 80 / 192;
|
||||
double allowedDist = factor * graph.ScalingFactor * 80;
|
||||
|
||||
Int2 dist = new(screenCachePos.x - screenMousePos.x,
|
||||
screenCachePos.y - screenMousePos.y);
|
||||
|
||||
@ -71,7 +71,7 @@ public class EquationDifference : Graphable, ITranslatableX, IConvertEquation
|
||||
Int2 diff = new(screenMousePos.x - nearestPixelPoint.x,
|
||||
screenMousePos.y - nearestPixelPoint.y);
|
||||
int dist = (int)Math.Sqrt(diff.x * diff.x + diff.y * diff.y);
|
||||
return dist < 50 * factor * graph.DpiFloat / 192;
|
||||
return dist < 50 * factor * graph.ScalingFactor;
|
||||
}
|
||||
public override IEnumerable<IGraphPart> GetSelectionItemsToRender(in GraphForm graph, Float2 graphMousePos)
|
||||
{
|
||||
|
||||
@ -54,7 +54,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable
|
||||
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;
|
||||
epsilon *= graph.ScalingFactor;
|
||||
List<IGraphPart> lines = [];
|
||||
|
||||
Int2 originLocation = graph.GraphSpaceToScreenSpace(new Float2(0, 0));
|
||||
@ -227,7 +227,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable
|
||||
Int2 screenPos = graph.GraphSpaceToScreenSpace(new Float2(graphMousePos.x,
|
||||
IntegralAtPoint(graphMousePos.x)));
|
||||
|
||||
double allowedDist = factor * graph.DpiFloat * 80 / 192;
|
||||
double allowedDist = factor * graph.ScalingFactor * 80;
|
||||
|
||||
Int2 dist = new(screenPos.x - screenMousePos.x,
|
||||
screenPos.y - screenMousePos.y);
|
||||
|
||||
@ -111,7 +111,7 @@ public class SlopeField : Graphable
|
||||
if (graphMousePos.x < Math.Min(line.a.x, line.b.x) ||
|
||||
graphMousePos.x > Math.Max(line.a.x, line.b.x)) return false;
|
||||
|
||||
double allowedDist = factor * graph.DpiFloat * 10 / 192;
|
||||
double allowedDist = factor * graph.ScalingFactor * 10;
|
||||
|
||||
double lineX = graphMousePos.x,
|
||||
lineY = slope * (lineX - nearestPos.x) + nearestPos.y;
|
||||
|
||||
@ -100,7 +100,7 @@ public class TangentLine : Graphable, IConvertEquation, ITranslatableX
|
||||
if (graphMousePos.x < Math.Min(line.a.x - 0.25, line.b.x - 0.25) ||
|
||||
graphMousePos.x > Math.Max(line.a.x + 0.25, line.b.x + 0.25)) return false;
|
||||
|
||||
double allowedDist = factor * graph.DpiFloat * 80 / 192;
|
||||
double allowedDist = factor * graph.ScalingFactor * 80;
|
||||
|
||||
double lineX = graphMousePos.x,
|
||||
lineY = currentSlope.x * (lineX - Position) + currentSlope.y;
|
||||
|
||||
@ -24,7 +24,7 @@ public record struct GraphUiCircle : IGraphPart
|
||||
if (!double.IsFinite(center.x) || !double.IsFinite(center.y) ||
|
||||
!double.IsFinite(radius) || radius == 0) return;
|
||||
|
||||
int rad = (int)(form.DpiFloat * radius / 192);
|
||||
int rad = (int)(form.ScalingFactor * radius);
|
||||
|
||||
Int2 centerPix = form.GraphSpaceToScreenSpace(center);
|
||||
g.FillEllipse(pen.Brush, new Rectangle(new Point(centerPix.x - rad,
|
||||
|
||||
@ -74,8 +74,8 @@ public record struct GraphUiText : IGraphPart
|
||||
break;
|
||||
}
|
||||
|
||||
posScreen.x += (int)(offsetPix.x * form.DpiFloat / 192);
|
||||
posScreen.y += (int)(offsetPix.y * form.DpiFloat / 192);
|
||||
posScreen.x += (int)(offsetPix.x * form.ScalingFactor);
|
||||
posScreen.y += (int)(offsetPix.y * form.ScalingFactor);
|
||||
|
||||
if (background)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user