Made most of the methods in virtual.
This commit is contained in:
parent
5c3cf9cafe
commit
7ff3720b70
@ -7,12 +7,12 @@ public abstract class Graphable
|
||||
private static int defaultColorsUsed;
|
||||
public static readonly uint[] DefaultColors =
|
||||
[
|
||||
0xEF_B34D47, // Red
|
||||
0xEF_4769B3, // Blue
|
||||
0xEF_50B347, // Green
|
||||
0xEF_7047B3, // Purple
|
||||
0xEF_B38B47, // Orange
|
||||
0xEF_5B5B5B // Black
|
||||
0xFF_B34D47, // Red
|
||||
0xFF_4769B3, // Blue
|
||||
0xFF_50B347, // Green
|
||||
0xFF_7047B3, // Purple
|
||||
0xFF_B38B47, // Orange
|
||||
0xFF_5B5B5B // Black
|
||||
];
|
||||
|
||||
public Color Color { get; set; }
|
||||
|
||||
@ -32,7 +32,6 @@ public class ColumnTable : Graphable
|
||||
tableXY.Add(x, equ(x));
|
||||
}
|
||||
|
||||
public override void EraseCache() { }
|
||||
public override long GetCacheBytes() => 16 * tableXY.Count;
|
||||
|
||||
public override Graphable DeepCopy() => new ColumnTable(width / 0.75, tableXY.ToArray().ToDictionary());
|
||||
|
||||
@ -111,10 +111,8 @@ public class Equation : Graphable
|
||||
double totalDist = Math.Sqrt(dist.x * dist.x + dist.y * dist.y);
|
||||
return totalDist <= allowedDist;
|
||||
}
|
||||
public override Float2 GetSelectedPoint(in GraphForm graph, Float2 graphMousePos)
|
||||
{
|
||||
return new(graphMousePos.x, GetFromCache(graphMousePos.x, 0.001));
|
||||
}
|
||||
public override Float2 GetSelectedPoint(in GraphForm graph, Float2 graphMousePos) =>
|
||||
new(graphMousePos.x, GetFromCache(graphMousePos.x, 1e-3));
|
||||
|
||||
public override void Preload(Float2 xRange, Float2 yRange, double step)
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ public class TangentLine : Graphable
|
||||
_position = value;
|
||||
}
|
||||
}
|
||||
private double _position;
|
||||
private double _position; // Private because it has exactly the same functionality as `Position`.
|
||||
|
||||
protected readonly Equation parent;
|
||||
protected readonly EquationDelegate parentEqu;
|
||||
|
||||
@ -6,6 +6,10 @@ Currently, it doesn't have a whole lot of features, but I'll be adding more in t
|
||||
- Graph an equation (duh).
|
||||
- There are currently some rendering issues with asymptotes which will be focused on at some point.
|
||||
- Graph a slope field of a `dy/dx =` style equation.
|
||||
- View a tangent line of an equation.
|
||||
- Display a vertical bar graph.
|
||||
|
||||
However, you can develop your own features as well.
|
||||
|
||||
The system does not and likely will not (at least for a while) support text-to-equation parsing. You must import this project as a library and add graphs that way.
|
||||
|
||||
|
||||
@ -14,13 +14,14 @@ internal static class Program
|
||||
|
||||
GraphForm graph = new("One Of The Graphing Calculators Of All Time");
|
||||
|
||||
Equation possibleA = new(x => x * x * x);
|
||||
SlopeField sf = new(2, (x, y) => 3 * x * x);
|
||||
TangentLine tl = new(5, 2, possibleA);
|
||||
Equation possibleA = 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);
|
||||
|
||||
// You can also now view and reset caches in the UI by going to
|
||||
// Misc > View Caches.
|
||||
// You can preload graphs in by going Misc > Preload Cache.
|
||||
// Keep in mind this uses more memory than usual and can take
|
||||
// some time.
|
||||
|
||||
Application.Run(graph);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user