Class FastTextureBuffer
- Namespace
- WitShells.CanvasDrawTool
High-performance texture buffer using byte array for Android optimization. Based on DirectTextureDrawing approach for maximum performance. Uses direct byte manipulation instead of Color struct for speed. (Android optimized)
public class FastTextureBuffer
- Inheritance
-
FastTextureBuffer
- Inherited Members
Constructors
FastTextureBuffer(int, int)
public FastTextureBuffer(int width, int height)
Parameters
FastTextureBuffer(int, int, Color32)
public FastTextureBuffer(int width, int height, Color32 fillColor)
Parameters
Properties
Data
public byte[] Data { get; }
Property Value
- byte[]
Height
public int Height { get; }
Property Value
IsDirty
public bool IsDirty { get; }
Property Value
Width
public int Width { get; }
Property Value
Methods
ApplyToTexture(Texture2D)
Apply buffer to texture (optimized partial update if possible).
public void ApplyToTexture(Texture2D texture)
Parameters
textureTexture2D
Clear(Color32)
Clear entire buffer with color.
public void Clear(Color32 color)
Parameters
colorColor32
CopyFrom(FastTextureBuffer)
Copy data from another buffer.
public void CopyFrom(FastTextureBuffer source)
Parameters
sourceFastTextureBuffer
DrawCircle(int, int, int, Color32, float, float)
Draw a filled circle (brush stamp) - highly optimized.
public void DrawCircle(int centerX, int centerY, int radius, Color32 color, float opacity, float hardness)
Parameters
DrawLine(int, int, int, int, Color32, int, float, float)
Draw a line using Bresenham's algorithm (your optimized approach).
public void DrawLine(int x0, int y0, int x1, int y1, Color32 color, int thickness, float opacity, float hardness)
Parameters
DrawPixelBlend(int, int, Color32, float)
Draw pixel with Color32 and opacity blending.
public void DrawPixelBlend(int x, int y, Color32 color, float opacity)
Parameters
DrawPixelBlend(int, int, byte, byte, byte, byte, float)
Draw pixel with alpha blending (optimized).
public void DrawPixelBlend(int x, int y, byte r, byte g, byte b, byte brushAlpha, float opacity)
Parameters
EraseCircle(int, int, int, float, float)
Erase a circle area.
public void EraseCircle(int centerX, int centerY, int radius, float opacity, float hardness)
Parameters
EraseLine(int, int, int, int, int, float, float)
Erase along a line.
public void EraseLine(int x0, int y0, int x1, int y1, int thickness, float opacity, float hardness)
Parameters
ErasePixel(int, int, float)
Erase pixel (reduce alpha).
public void ErasePixel(int x, int y, float eraseStrength)
Parameters
GetDataCopy()
Get a copy of the data for undo.
public byte[] GetDataCopy()
Returns
- byte[]
GetPixel(int, int)
Get pixel as Color32 (fast).
public Color32 GetPixel(int x, int y)
Parameters
Returns
- Color32
LoadFromTexture(Texture2D)
Initialize from existing texture.
public void LoadFromTexture(Texture2D texture)
Parameters
textureTexture2D
RestoreFromData(byte[])
Restore from data copy.
public void RestoreFromData(byte[] data)
Parameters
databyte[]
SetPixel(int, int, Color32)
Set pixel with Color32 (no blending, very fast).
public void SetPixel(int x, int y, Color32 color)
Parameters
SetPixelDirect(int, int, byte, byte, byte, byte)
Set pixel directly (fastest, no blending).
public void SetPixelDirect(int x, int y, byte r, byte g, byte b, byte a)