mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
DrawArray and some other things
This commit is contained in:
parent
f0121b1fe3
commit
d5e82612e9
1 changed files with 58 additions and 6 deletions
|
|
@ -1,7 +1,10 @@
|
||||||
//#define COSMOSDEBUG
|
//#define COSMOSDEBUG
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Cosmos.System.Graphics
|
namespace Cosmos.System.Graphics
|
||||||
{
|
{
|
||||||
public abstract class Canvas
|
public abstract class Canvas
|
||||||
|
|
@ -294,6 +297,13 @@ namespace Cosmos.System.Graphics
|
||||||
DrawLine(pen, points[0], points[points.Length - 1]);
|
DrawLine(pen, points[0], points[points.Length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void DrawRectangle(Pen pen, Point point, int width, int height = -1)
|
||||||
|
{
|
||||||
|
|
||||||
|
DrawRectangle(pen, point.X, point.Y, width, height);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void DrawRectangle(Pen pen, int x, int y, int width, int height = -1)
|
public virtual void DrawRectangle(Pen pen, int x, int y, int width, int height = -1)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
@ -375,17 +385,56 @@ namespace Cosmos.System.Graphics
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void DrawArray(Color[] colors, Point point, int width, int height = -1)
|
||||||
|
{
|
||||||
|
|
||||||
|
DrawArray(colors, point.X, point.Y, width, height);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void DrawArray(Color[] colors, int x, int y, int width, int height = -1)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (height == -1)
|
||||||
|
{
|
||||||
|
height = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThrowIfCoordNotValid(x, y);
|
||||||
|
|
||||||
|
ThrowIfCoordNotValid(x + width, y + height);
|
||||||
|
|
||||||
|
for (int i = 0; i < x; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int ii = 0; ii < y; ii++)
|
||||||
|
{
|
||||||
|
|
||||||
|
DrawPoint(new Pen(colors[i + (ii * width)]), new Point(i, ii));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void DrawRectangle(Pen pen, float x_start, float y_start, float width, float height)
|
public void DrawRectangle(Pen pen, float x_start, float y_start, float width, float height)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Image and Font will be available in .NET Core 2.1
|
// Image and Font will be available in .NET Core 2.1
|
||||||
|
// dot net core does not have Image
|
||||||
//public void DrawImage(Image image, int x, int y)
|
//public void DrawImage(Image image, int x, int y)
|
||||||
//{
|
//{
|
||||||
// throw new NotImplementedException();
|
// throw new NotImplementedException();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
//public void DrawString(String str, Font aFont, Brush brush, Point point)
|
||||||
|
//{
|
||||||
|
// DrawString(str, aFont, brush, point.X, point.Y);
|
||||||
|
//}
|
||||||
|
|
||||||
//public void DrawString(String str, Font aFont, Brush brush, int x, int y)
|
//public void DrawString(String str, Font aFont, Brush brush, int x, int y)
|
||||||
//{
|
//{
|
||||||
// throw new NotImplementedException();
|
// throw new NotImplementedException();
|
||||||
|
|
@ -398,6 +447,13 @@ namespace Cosmos.System.Graphics
|
||||||
if (mode == null)
|
if (mode == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* This would have been the more "modern" version but LINQ is not working
|
||||||
|
|
||||||
|
if (!availableModes.Exists(element => element == mode))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
foreach (var elem in availableModes)
|
foreach (var elem in availableModes)
|
||||||
{
|
{
|
||||||
if (elem == mode)
|
if (elem == mode)
|
||||||
|
|
@ -416,11 +472,7 @@ namespace Cosmos.System.Graphics
|
||||||
Global.mDebugger.SendInternal($"mode is null raising exception!");
|
Global.mDebugger.SendInternal($"mode is null raising exception!");
|
||||||
throw new ArgumentNullException(nameof(mode));
|
throw new ArgumentNullException(nameof(mode));
|
||||||
}
|
}
|
||||||
#if false
|
|
||||||
/* This would have been the more "modern" version but LINQ is not working */
|
|
||||||
if (!availableModes.Exists(element => element == mode))
|
|
||||||
throw new ArgumentOutOfRangeException($"Mode {mode} is not supported by this Driver");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (CheckIfModeIsValid(mode))
|
if (CheckIfModeIsValid(mode))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue