Skip to content

Allows for individual pixel control over the pixels in MonoGame, extendable with some default drawing functions.

License

Notifications You must be signed in to change notification settings

thepigeongenerator/PixelControlLayer

Repository files navigation

ThePigeonGenerator.MonoGame.PixelControlLayer

A library to allow for setting individual pixels in a MonoGame project. Is easily extendable with your own functions for more advanced drawing.

Installation

Windows in Visual Studio:

  1. Follow the steps here.
  2. Search the package namespace seen above.

Universal:

  1. Select the package under the Packages tab on the right.
  2. Select the version you'd like to install
  3. Run the command listed above in the directory of the project you wish to install the package in.
Default* Extensions
SetPoint(this PixelControlLayer pcl, int x, int y, Color colour)
SetLine(this PixelControlLayer pcl, int x1, int y1, int x2, int y2, Color colour)
SetBox(this PixelControlLayer pcl, int x1, int y1, int x2, int y2, Color colour)
SetCircle(this PixelControlLayer pcl, int centreX, int centreY, Color colour)

*It is possible to add more extensions yourself; read more about the different components you're able to modify in PixelControlLayer

Example

protected override void Initialize()
{
    // define the pixel control layer using the graphics device to set the correct internal texture size
    _pixelControlLayer = new PixelControlLayer(_graphics.GraphicsDevice);

    // OR: define your own size
    _pixelControlLayer = new PixelControlLayer(_graphics.GraphicsDevice, 64, 64);

    base.Initialize();
}
protected override void Update()
{
    // draw something to the pixel control layer
    _pixelControlLayer.SetCircle(50, 50, 10, Color.Red);

    base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.Clear(Color.Black);

    _spriteBatch.Begin();

    _pixelControlLayer.Draw(_spriteBatch); // assumes the default position of (0, 0)

    _spriteBatch.End();
    _pixelControlLayer.ClearBuffer(); // clear the internal buffer *after* drawing, otherwise it'll fail to draw

    base.Draw(gameTime);
}

About

Allows for individual pixel control over the pixels in MonoGame, extendable with some default drawing functions.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages