Hello,
In order to test a Noise function I've translated from JavaScript, I need to learn first how to create images from arrays.
I've naively tried the following
fn assets_loading(mut commands: Commands, mut assets: ResMut<Assets<Image>>) {
let mut data: Vec<u8> = Vec::new();
for i in 0..255 {
data.push(50);
data.push(255);
data.push(50);
data.push(255);
}
let image = Image::new(Extent3d {
width: 1,
height: 1,
depth_or_array_layers: 1
}, TextureDimension::D2, data, TextureFormat::Rgba16Unorm);
commands.insert_resource(WorldAssets {
texture: assets.add(image),
})
}
but I receive thread 'main' panicked at 'cannot get pixel info for type' because (I suspect) the data array is not of the expected size.
My question is how can I exactly know the size of the data: Vec<u8> I need to build?
Thanks