Skip to content

Commit e75262f

Browse files
authored
Merge pull request #628 from DjAlEx234/master
Canvas Update
2 parents d4fc437 + adfb302 commit e75262f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

source/Cosmos.System/Graphics/Canvas.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private void DrawHorizontalLine(Pen pen, int dx, int x1, int y1)
100100
DrawPoint(pen, x1 + i, y1);
101101
}
102102

103-
private void DrawVerthicalLine(Pen pen, int dy, int x1, int y1)
103+
private void DrawVerticalLine(Pen pen, int dy, int x1, int y1)
104104
{
105105
int i;
106106

@@ -159,7 +159,7 @@ private void DrawDiagonalLine(Pen pen, int dx, int dy, int x1, int y1)
159159
* DrawLine throw if the line goes out of the boundary of the Canvas, probably will be better to draw only the part
160160
* of line visibile. This is too "smart" to do here better do it in a future Window Manager.
161161
*/
162-
public void DrawLine(Pen pen, int x1, int y1, int x2, int y2)
162+
public virtual void DrawLine(Pen pen, int x1, int y1, int x2, int y2)
163163
{
164164
if (pen == null)
165165
throw new ArgumentOutOfRangeException(nameof(pen));
@@ -181,7 +181,7 @@ public void DrawLine(Pen pen, int x1, int y1, int x2, int y2)
181181

182182
if (dx == 0) /* the line is vertical */
183183
{
184-
DrawVerthicalLine(pen, dy, x1, y1);
184+
DrawVerticalLine(pen, dy, x1, y1);
185185
return;
186186
}
187187

@@ -283,7 +283,7 @@ public virtual void DrawPolygon(Pen pen, params Point[] points)
283283
DrawLine(pen, points[0], points[points.Length - 1]);
284284
}
285285

286-
public void DrawRectangle(Pen pen, int x, int y, int width, int height)
286+
public virtual void DrawRectangle(Pen pen, int x, int y, int width, int height)
287287
{
288288
/*
289289
* we must draw four lines connecting any vertex of our rectangle to do this we first obtain the position of these
@@ -323,6 +323,22 @@ public void DrawRectangle(Pen pen, int x, int y, int width, int height)
323323
DrawLine(pen, xc, yc, xd, yd);
324324
}
325325

326+
public virtual void DrawFilledRectangle(Pen pen, int x_start, int y_start, int width, int height)
327+
{
328+
for (int i = 0; i != width; i++)
329+
{
330+
DrawLine(pen, x_start, y_start, x_start + height, y_start);
331+
y_start++;
332+
}
333+
}
334+
335+
public virtual void DrawTriangle(Pen pen, int v1x, int v1y, int v2x, int v2y, int v3x, int v3y)
336+
{
337+
DrawLine(pen, v1x, v1y, v2x, v2y);
338+
DrawLine(pen, v1x, v1y, v3x, v3y);
339+
DrawLine(pen, v2x, v2y, v3x, v3y);
340+
}
341+
326342
public void DrawRectangle(Pen pen, float x_start, float y_start, float width, float height)
327343
{
328344
throw new NotImplementedException();

0 commit comments

Comments
 (0)