This example is running in WebGL2 and should work in most browsers. You can check the WebGPU examples here.
cpu_draw.rs:
//! Example of how to draw to a texture from the CPU.
//!
//! You can set the values of individual pixels to whatever you want.
//! Bevy provides user-friendly APIs that work with [`Color`](bevy::color::Color)
//! values and automatically perform any necessary conversions and encoding
//! into the texture's native pixel format.
use ;
use *;
use ;
use Rng;
const IMAGE_WIDTH: u32 = 256;
const IMAGE_HEIGHT: u32 = 256;
/// Store the image handle that we will draw to, here.
;
/// Every fixed update tick, draw one more pixel to make a spiral pattern