Table of Contents

Class FastTextureBuffer

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

width int
height int

FastTextureBuffer(int, int, Color32)

public FastTextureBuffer(int width, int height, Color32 fillColor)

Parameters

width int
height int
fillColor Color32

Properties

Data

public byte[] Data { get; }

Property Value

byte[]

Height

public int Height { get; }

Property Value

int

IsDirty

public bool IsDirty { get; }

Property Value

bool

Width

public int Width { get; }

Property Value

int

Methods

ApplyToTexture(Texture2D)

Apply buffer to texture (optimized partial update if possible).

public void ApplyToTexture(Texture2D texture)

Parameters

texture Texture2D

Clear(Color32)

Clear entire buffer with color.

public void Clear(Color32 color)

Parameters

color Color32

CopyFrom(FastTextureBuffer)

Copy data from another buffer.

public void CopyFrom(FastTextureBuffer source)

Parameters

source FastTextureBuffer

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

centerX int
centerY int
radius int
color Color32
opacity float
hardness float

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

x0 int
y0 int
x1 int
y1 int
color Color32
thickness int
opacity float
hardness float

DrawPixelBlend(int, int, Color32, float)

Draw pixel with Color32 and opacity blending.

public void DrawPixelBlend(int x, int y, Color32 color, float opacity)

Parameters

x int
y int
color Color32
opacity float

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

x int
y int
r byte
g byte
b byte
brushAlpha byte
opacity float

EraseCircle(int, int, int, float, float)

Erase a circle area.

public void EraseCircle(int centerX, int centerY, int radius, float opacity, float hardness)

Parameters

centerX int
centerY int
radius int
opacity float
hardness float

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

x0 int
y0 int
x1 int
y1 int
thickness int
opacity float
hardness float

ErasePixel(int, int, float)

Erase pixel (reduce alpha).

public void ErasePixel(int x, int y, float eraseStrength)

Parameters

x int
y int
eraseStrength float

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

x int
y int

Returns

Color32

LoadFromTexture(Texture2D)

Initialize from existing texture.

public void LoadFromTexture(Texture2D texture)

Parameters

texture Texture2D

RestoreFromData(byte[])

Restore from data copy.

public void RestoreFromData(byte[] data)

Parameters

data byte[]

SetPixel(int, int, Color32)

Set pixel with Color32 (no blending, very fast).

public void SetPixel(int x, int y, Color32 color)

Parameters

x int
y int
color Color32

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)

Parameters

x int
y int
r byte
g byte
b byte
a byte