Bitmap Drawing API extension methods for Unity's Texture2D class.
Web demo
Shows a texture with some basic bitmap operations on it.
What is it?
By default, Texture2D only provides the methods SetPixel and GetPixel (and SetPixels and GetPixels). This library extends that functionality with useful basic drawing operations. It outputs pixel perfect and not anti-aliased bitmaps.
Extension Methods
C# Extension Methods work in a way that adds methods to a existing class. To start using this, you only need to include the namespace:
using ProtoTurtle.BitmapDrawing;
Your Texture2D instances will then have all the new methods available.
Features:
DrawPixel(position, color) - Draws a pixel but with the top left corner being position (x = 0, y = 0)
DrawLine(start, end, color) - Draws a line between two points
DrawCircle(position, radius, color) - Draws a circle
DrawFilledCircle(position, radius, color) - Draws a circle filled with a color
DrawRectangle(rectangle, color) - Draws a rectangle or a square
DrawFilledRectangle(rectangle, color) - Draws a rectangle or a square filled with a color
FloodFill(position, color) - Starts a flood fill of a certaing at the point
x = 0, y = 0 is the top left corner
This library uses the convention of having the left top corner of the bitmap be the 0, 0 position. By default, Texture2D uses the bottom left corner convention which can be confusing for bitmap operations.