Added a postprocessing v1 to both tools
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace Paint_2
|
||||
{
|
||||
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
||||
drawing = false;
|
||||
sketch.StopDrawing();
|
||||
RefreshUi();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user