Added a postprocessing v1 to both tools

This commit is contained in:
2022-05-31 15:46:52 +02:00
parent 6d4ee29a2e
commit c3728b01fc
5 changed files with 51 additions and 7 deletions

View File

@@ -88,9 +88,31 @@ namespace Paint_2
Widths = new List<int>();
WidthsRedo = new List<int>();
}
public void Stop(Point point)
public void Stop()
{
throw new NotImplementedException();
List<Point> Drawing = Drawings[Drawings.Count - 1];
Drawings[Drawings.Count - 1] = PostProcessing(Drawing);
}
private List<Point> PostProcessing(List<Point> Drawing)
{
//THIS SHOULD BE REMOVED, IT IS ONLY HERE TO BE EASIER TO DEBUG THE CONCEPT
List<Point> NewDrawing = new List<Point>();
Point previous = new Point(-1, -1);
//Implementing a post processing
foreach (Point point in Drawing)
{
if (previous != new Point(-1, -1))
{
NewDrawing.Add(new Point((previous.X + point.X) / 2, (previous.Y + point.Y) / 2));
previous = point;
}
else
{
previous = point;
}
NewDrawing.Add(point);
}
return NewDrawing;
}
public List<Color> GetLastColors(int colorNumber)
{

View File

@@ -60,6 +60,7 @@ namespace Paint_2
{
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
drawing = false;
sketch.StopDrawing();
RefreshUi();
}

View File

@@ -25,7 +25,7 @@ namespace Paint_2
string Name { get; set; }
void Start(Color color, int width);
void Stop(Point point);
void Stop();
void Add(Point point);
void Undo();
void Redo();

View File

@@ -89,9 +89,30 @@ namespace Paint_2
Widths = new List<int>();
WidthsRedo = new List<int>();
}
public void Stop(Point point)
public void Stop()
{
throw new NotImplementedException();
List<Point> Drawing = Drawings[Drawings.Count - 1];
Drawings[Drawings.Count - 1] = PostProcessing(Drawing);
}
private List<Point> PostProcessing(List<Point> Drawing)
{
List<Point> NewDrawing = new List<Point>();
Point previous = new Point(-1, -1);
//Implementing a post processing
foreach (Point point in Drawing)
{
if (previous != new Point(-1, -1))
{
NewDrawing.Add(new Point((previous.X + point.X)/2,(previous.Y + point.Y)/2));
previous = point;
}
else
{
previous = point;
}
NewDrawing.Add(point);
}
return NewDrawing;
}
public List<Color> GetLastColors(int colorNumber)
{

View File

@@ -92,9 +92,9 @@ namespace Paint_2
{
CurrentTool.Start(CurrentTool.Color, width);
}
public void StopDrawing(Point location)
public void StopDrawing()
{
CurrentTool.Stop(location);
CurrentTool.Stop();
}
public void AddDrawingPoint(Point location)
{