C# Class ProtoTurtle.BitmapDrawing.BitmapDrawingExtensions

A extension class for UnityEngine.Texture2D that provides a bitmap drawing API. Provides drawing methods line Line, Circle, Rectangle etc. This class uses a convention of having the 0,0 point at the left-top corner!
Check this out for more cool middleware stuff: http://prototurtle.com
Afficher le fichier Open project: abagames/pongpector

Méthodes publiques

Méthode Description
DrawCircle ( this texture, int x, int y, int radius, Color color ) : void

Draws a circle with the midpoint being x0, x1. Implementation of Bresenham's circle algorithm

DrawFilledCircle ( this texture, int x, int y, int radius, Color color ) : void

Draws a filled circle with the midpoint being x0, x1. Implementation of Bresenham's circle algorithm

DrawFilledRectangle ( this texture, Rect rectangle, Color color ) : void

Fills the given rectangle area with a solid color.

DrawLine ( this texture, Vector2 start, Vector2 end, Color color ) : void
DrawLine ( this texture, Vector3 start, Vector3 end, Color color ) : void
DrawLine ( this texture, int x0, int y0, int x1, int y1, Color color ) : void

Draws a line between two points. Implementation of Bresenham's line algorithm.

DrawPixel ( this texture, int x, int y, Color color ) : void

Draws a pixel just like SetPixel except 0,0 is the left top corner.

DrawPixel ( this texture, int x, int y, int width, int height, Color color ) : void

Draws a pixel just like SetPixel except 0,0 is the left top corner. Takes the width and height as parameters - faster for calling this in a loop.

DrawRectangle ( this texture, Rect rectangle, Color color ) : void

Draws a rectangle

FloodFill ( this texture, int startX, int startY, Color newColor ) : void

Starts a flood fill at point startX, startY. This is a pretty slow flood fill, biggest bottle neck is comparing two colors which happens a lot. Should be a way to make it much faster. O(n) space. n = width*height - makes a copy of the bitmap temporarily in the memory

Private Methods

Méthode Description
Circle ( Texture2D texture, int x, int y, int radius, Color color, bool filled = false ) : void
Line ( Texture2D texture, int x0, int y0, int x1, int y1, Color color ) : void
PlotCircle ( Texture2D texture, int cx, int x, int cy, int y, Color color ) : void
ScanLineCircle ( Texture2D texture, int cx, int x, int cy, int y, Color color ) : void
Swap ( int &x, int &y ) : void

Swap two ints by reference.

TransformToLeftTop_y ( float y, int height ) : int

Transforms a point in the texture plane so that 0,0 points at left-top corner.

TransformToLeftTop_y ( int y, int height ) : int

Transforms a point in the texture plane so that 0,0 points at left-top corner.

Method Details

DrawCircle() public static méthode

Draws a circle with the midpoint being x0, x1. Implementation of Bresenham's circle algorithm
public static DrawCircle ( this texture, int x, int y, int radius, Color color ) : void
texture this
x int
y int
radius int
color Color
Résultat void

DrawFilledCircle() public static méthode

Draws a filled circle with the midpoint being x0, x1. Implementation of Bresenham's circle algorithm
public static DrawFilledCircle ( this texture, int x, int y, int radius, Color color ) : void
texture this
x int
y int
radius int
color Color
Résultat void

DrawFilledRectangle() public static méthode

Fills the given rectangle area with a solid color.
public static DrawFilledRectangle ( this texture, Rect rectangle, Color color ) : void
texture this
rectangle UnityEngine.Rect
color Color
Résultat void

DrawLine() public static méthode

public static DrawLine ( this texture, Vector2 start, Vector2 end, Color color ) : void
texture this
start Vector2
end Vector2
color Color
Résultat void

DrawLine() public static méthode

public static DrawLine ( this texture, Vector3 start, Vector3 end, Color color ) : void
texture this
start Vector3
end Vector3
color Color
Résultat void

DrawLine() public static méthode

Draws a line between two points. Implementation of Bresenham's line algorithm.
public static DrawLine ( this texture, int x0, int y0, int x1, int y1, Color color ) : void
texture this
x0 int x of the start point
y0 int y of the start point
x1 int x of the end point
y1 int y of the end point
color Color
Résultat void

DrawPixel() public static méthode

Draws a pixel just like SetPixel except 0,0 is the left top corner.
public static DrawPixel ( this texture, int x, int y, Color color ) : void
texture this
x int
y int
color Color
Résultat void

DrawPixel() public static méthode

Draws a pixel just like SetPixel except 0,0 is the left top corner. Takes the width and height as parameters - faster for calling this in a loop.
public static DrawPixel ( this texture, int x, int y, int width, int height, Color color ) : void
texture this
x int
y int
width int Width of the target bitmap
height int Height of the target bitmap
color Color
Résultat void

DrawRectangle() public static méthode

Draws a rectangle
public static DrawRectangle ( this texture, Rect rectangle, Color color ) : void
texture this
rectangle UnityEngine.Rect
color Color
Résultat void

FloodFill() public static méthode

Starts a flood fill at point startX, startY. This is a pretty slow flood fill, biggest bottle neck is comparing two colors which happens a lot. Should be a way to make it much faster. O(n) space. n = width*height - makes a copy of the bitmap temporarily in the memory
public static FloodFill ( this texture, int startX, int startY, Color newColor ) : void
texture this
startX int
startY int
newColor Color
Résultat void