Private
Public Access
Made filling work properly
This commit is contained in:
1 parent
11fca1fad4
commit
dd9e961352
1 file changed
+10
-10
@@ -27,7 +27,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Brush object
|
/// The Brush object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Brush brush;
|
protected SolidBrush brush;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Pen object
|
/// The Pen object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -87,11 +87,11 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows the filling of objects.
|
/// Allows the filling of objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnableFill() => fill = false;
|
public void EnableFill() => fill = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disables the filling of objects.
|
/// Disables the filling of objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void DisableFill() => fill = true;
|
public void DisableFill() => fill = false;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the filling of objects
|
/// Set the filling of objects
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -113,7 +113,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// Set fill color
|
/// Set fill color
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Fill color</param>
|
/// <param name="color">Fill color</param>
|
||||||
public void SetFillColor(Color color) => ((SolidBrush)brush).Color = color;
|
public void SetFillColor(Color color) => brush.Color = color;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draws a line from the current pen position to the one specified in the parameter. This also sets the pens new position.
|
/// Draws a line from the current pen position to the one specified in the parameter. This also sets the pens new position.
|
||||||
@@ -129,18 +129,17 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="points">Points to draw to</param>
|
/// <param name="points">Points to draw to</param>
|
||||||
public void DrawLines(Point[] points) {
|
public void DrawLines(Point[] points) {
|
||||||
|
|
||||||
if (points.Length < 2) {
|
if (points.Length < 2) {
|
||||||
throw new Exception("Cannot have less than two points in a line");
|
throw new Exception("Cannot have less than two points in a line");
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsPath path = new GraphicsPath();
|
GraphicsPath path = new GraphicsPath();
|
||||||
|
path.FillMode = FillMode.Winding;
|
||||||
|
|
||||||
for (int i = 1; i < points.Length; i++) {
|
path.AddLines(points);
|
||||||
path.AddLine(points[i - 1], points[i]);
|
path.AddLine(points[0], points.Last()); //Add final line
|
||||||
}
|
|
||||||
|
|
||||||
path.AddLine(points[0], points.Last());
|
|
||||||
|
|
||||||
DrawLines(path);
|
DrawLines(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +158,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scale">Scale of the circle</param>
|
/// <param name="scale">Scale of the circle</param>
|
||||||
public void DrawCircle(double scale) {
|
public void DrawCircle(double scale) {
|
||||||
|
if (fill) graphics.FillEllipse(brush, penPosition.X - (float)(scale), penPosition.Y - (float)(scale), (float)scale * 2, (float)scale * 2);
|
||||||
graphics.DrawEllipse(pen, penPosition.X - (float)(scale), penPosition.Y - (float)(scale), (float)scale * 2, (float)scale * 2);
|
graphics.DrawEllipse(pen, penPosition.X - (float)(scale), penPosition.Y - (float)(scale), (float)scale * 2, (float)scale * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user