FillRectangle 4 Comments

7:27 pm on December 31, 2009

public static void FillRectangle(uint lx, uint ly, uint sx, uint sy, uint colour)
{
for
(uint xx = lx; xx < sx + lx; xx++)
{
for
(uint yy = ly; yy < sy + ly; yy++)
{
if
(xx <= 319 && xx >= 0)
screenbuffer[yy * 320 + xx] = colour; //If you are using a uint[] as a screen buffer, use this, otherwise use this:
//Screen.SetPixel320x200x8(xx, yy, colour);
}
}
}

for this to work you use have

using Cosmos.Hardware;
using Screen = Cosmos.Hardware.VGAScreen;

private static uint[] screenbuffer = new uint[512000]; //Optional, you don’t need a buffer, but I recommend it;

and have added colors to the palette and added:

Screen.SetMode320x200x8();

before the main loop.

Comments (4) ↓ Add Comment

  1. Xanti SS says:

    Very nice function; any ideas for drawing ellipses? You could make a COSMOS graphics library ;)

  2. Weirdnes222222222222 says:

    what the hell dude? dont spam!

Leave a Reply

You must be logged in to post a comment.