Brush to Texture
A little painting app: drag to paint! Each brush stroke is stamped into a RenderTexture that accumulates everything drawn so far. Press C or click [ clear ] to erase.
// A render texture that only updates when we stamp() into it
var renderTexture = new RenderTexture(width, height);
renderTexture.autoRender = false;
renderTexture.clearOnRender = false;
// A quad displaying it
var canvas = new Quad();
canvas.texture = renderTexture;
add(canvas);
// Stamp a (not displayed) brush visual into the texture
renderTexture.stamp(brush, () -> {
// Stamped! The texture now contains the brush content
});
// Erase everything
renderTexture.clear(Color.WHITE, 0, () -> {});
Next example ➔ Gaussian Blur