Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ColorArray
- {
- public Color[] Colors { get; set; }
- public int Width { get; set; }
- public int Height { get; set; }
- public ColorArray()
- {
- }
- public ColorArray(int width, int height)
- {
- Width = width;
- Height = height;
- Colors = new Color[width * height];
- }
- public Color this[int index]
- {
- get
- {
- return Colors[index];
- }
- set
- {
- Colors[index] = value;
- }
- }
- public Color this[int x, int y]
- {
- get
- {
- if (x < 0 || x >= Width || y < 0 || y >= Height)
- {
- throw new IndexOutOfRangeException();
- }
- return Colors[x + y * Height];
- }
- set
- {
- if (x < 0 || x >= Width || y < 0 || y >= Height)
- {
- throw new IndexOutOfRangeException();
- }
- Colors[x + y * Height] = value;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement