using System.Collections; using System.Collections.Generic; using Godot; using System; namespace Rokojori { public class TextureBuffer { int _width; public int width => _width; int _height; public int height => _height; T[] _pixels; public static TextureBuffer Create( int w, int h ) { var tb = new TextureBuffer(); tb._height = h; tb._width = w; tb._pixels = new T[ w * h ]; return tb; } public int ComputeIndexFromPosition( int x, int y ) { return x + y * _width; } public void SetAt( int x, int y, T value ) { SetIndexed( ComputeIndexFromPosition( x, y ), value ); } public void SetIndexed( int index, T value ) { _pixels[ index ] = value; } public T GetAt( int x, int y ) { return GetIndexed( ComputeIndexFromPosition( x, y ) ); } public T GetIndexed( int index ) { return _pixels[ index ]; } } }