Changed ColorInterp

This commit is contained in:
glax 2023-04-23 13:06:47 +02:00
parent 68cb0ee3fd
commit 18822e2152

View File

@ -10,13 +10,11 @@ namespace RenderPath;
public static class Renderer
{
private const int ImageMaxSize = 20000;
private const float PenThickness = 3;
private const float PenThickness = 2;
private static readonly Color RouteColor = Color.Red;
private static readonly Color WeightStartColor = Color.FromArgb(200, 0, 0, 255);
private static readonly Color WeightCenterColor = Color.FromArgb(200,255, 255, 0);
private static readonly Color WeightEndColor = Color.FromArgb(200,0, 255, 0);
private static readonly Color RoadPrioStart = Color.FromArgb(100, 100, 100, 100);
private static readonly Color RoadPrioCenter = Color.FromArgb(255, 100, 200, 255);
private static readonly Color WeightStartColor = Color.FromArgb(127, 0, 100, 255);
private static readonly Color WeightEndColor = Color.FromArgb(255,0, 255, 0);
private static readonly Color RoadPrioStart = Color.FromArgb(200, 100, 100, 100);
private static readonly Color RoadPrioEnd = Color.FromArgb(255, 255, 180, 0);
public class Bounds
@ -78,7 +76,7 @@ public static class Renderer
OsmNode nNode = rm.GetNode(edge.neighborId, edge.neighborRegion)!;
Coordinates c2 = nNode.coordinates;
Pen p = new(GradientPick(priority, RoadPrioStart, RoadPrioCenter, RoadPrioEnd), PenThickness);
Pen p = new(ColorInterp(RoadPrioStart, RoadPrioEnd, priority), PenThickness);
float x1 = (c1.longitude - minLon) * scaleFactor;
float y1 = (maxLat - c1.latitude) * scaleFactor;
float x2 = (c2.longitude - minLon) * scaleFactor;
@ -165,7 +163,7 @@ public static class Renderer
foreach (KeyValuePair<OsmNode, double> kv in gScore)
{
double percentage = (kv.Value - minWeight) / (maxWeight - minWeight);
Brush b = new SolidBrush(GradientPick(percentage, WeightStartColor, WeightCenterColor, WeightEndColor));
Brush b = new SolidBrush(ColorInterp(WeightStartColor, WeightEndColor, percentage));
float x = (kv.Key.coordinates.longitude - minLon) * scaleFactor;
float y = (maxLat - kv.Key.coordinates.latitude) * scaleFactor;
@ -187,12 +185,4 @@ public static class Renderer
LinearInterp(start.R, end.R, percentage),
LinearInterp(start.G, end.G, percentage),
LinearInterp(start.B, end.B, percentage));
private static Color GradientPick(double percentage, Color Start, Color Center, Color End) {
if (percentage < 0.5)
return ColorInterp(Start, Center, percentage / 0.5);
else if (percentage == 0.5)
return Center;
else
return ColorInterp(Center, End, (percentage - 0.5)/0.5);
}
}