Cosmos/source/Cosmos.System/Graphics/Pen.cs
fanoI 73aa970508 CGS finally works!
Please note that this version works only with Bochs.

- To make it works was needed to renounce to all structures (a part for primitive types) so now Mode and Color are classes.
- Implemented methods of Canvas DrawPoint(), DrawLine() and DrawRect() for now only color depth of 32 bit and integer coordinates are supported
- Changed IoPort of Bochs / VBE to MemoryBlock and not MemoryBlock08 so I can write an 32 bit ARGB color in only an operation instead of 4, this will semplify the future
  work of RGB24 and RGB16 too. Changed the name to the correct one "LinearFrameBuffer".
- Made VBEDriver more object oriented (used enums instead of hardcoded values, created methods and so on...)
- Bugfix in the Pen class there was confusion in the setter / getter of the Color property
- In VBEScreen removed the old code that is not needed anymore, added check to method arguments (that throws in case of fatal errors)
2017-01-08 22:57:27 +01:00

64 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Diagnostics.Contracts;
namespace Cosmos.System.Graphics
{
/*
* This represents a Pen the same thing a drawer uses to paint.
* For now it is a very little abstraction it put together a color and the width of the Pen in future
* it could be more having maybe a concept of Style?
* It is a class because we want to permit to change the color of a Pen doing Pen.Color = <aColor> it could have been
* a struct but struct should be immutable so...
*/
public class Pen
{
Color color;
int width;
public Pen(Color color, int width = 1)
{
if (width < 1)
throw new ArgumentOutOfRangeException($"width ({width}) cannot be less than 1");
// Contract.Requires<ArgumentOutOfRangeException>(width >= 1, "thickness");
this.color = color;
this.width = width;
}
public Color Color
{
get
{
return color;
}
set
{
color = value;
}
}
public int Width
{
get
{
return width;
}
set
{
width = value;
}
}
public override String ToString()
{
return $"color: {color} width: {width}";
}
}
}