render-textures
Use this skill when using RenderTexture or DynamicTexture in Phaser 4. Covers drawing game objects to textures, dynamic texture creation, snapshot/screenshot, stamps, and off-screen rendering. Triggers on: RenderTexture, DynamicTexture, snapshot, draw to texture, stamp.
What this skill does
# Render Textures and Dynamic Textures
> Drawing game objects to off-screen textures in Phaser 4 -- RenderTexture game object, DynamicTexture for shared textures, the Stamp helper, command-buffer rendering, snapshots, procedural generation, and minimap patterns.
**Key source paths:** `src/gameobjects/rendertexture/`, `src/textures/DynamicTexture.js`, `src/gameobjects/stamp/`, `src/textures/typedefs/StampConfig.js`, `src/textures/typedefs/CaptureConfig.js`
**Related skills:** ../sprites-and-images/SKILL.md, ../loading-assets/SKILL.md, ../cameras/SKILL.md
## Quick Start
```js
// In a Scene's create() method:
// 1. RenderTexture -- a visible game object with its own DynamicTexture
const rt = this.add.renderTexture(400, 300, 256, 256);
rt.draw('player', 128, 128); // draw a texture by key at center
rt.fill(0x222244, 0.5); // semi-transparent fill
rt.render(); // flush the command buffer
// 2. DynamicTexture -- a shared texture in the Texture Manager
const dt = this.textures.addDynamicTexture('composite', 512, 512);
dt.stamp('coin', null, 64, 64, { scale: 2, angle: 45 });
dt.render();
this.add.image(400, 300, 'composite'); // any game object can use it
// 3. Stamp game object -- lightweight Image that ignores camera scroll
const hud = this.add.stamp(10, 10, 'heart');
```
## Core Concepts
### RenderTexture vs DynamicTexture
Phaser 4 splits texture-drawing into two layers:
| | RenderTexture | DynamicTexture |
|---|---|---|
| What it is | Image game object + auto-created DynamicTexture | Texture in the Texture Manager |
| Created via | `this.add.renderTexture(x, y, w, h)` | `this.textures.addDynamicTexture(key, w, h)` |
| Visible on its own | Yes (it extends Image) | No (must be assigned to a game object) |
| Shared across objects | Possible via `saveTexture(key)` | Yes, by key |
| Cross-scene use | No (belongs to one Scene) | Yes (textures are global) |
| Has position/scale/alpha | Yes (all Image components) | No (it is a Texture, not a GameObject) |
**When to use which:**
- Use **RenderTexture** when you need a single visible surface you draw onto (paint canvas, trail effect, composite sprite).
- Use **DynamicTexture** when many game objects share the same generated texture, or you need a texture for masks/shaders, or you need cross-scene access.
RenderTexture is a thin proxy. Methods like `draw()`, `stamp()`, `fill()`, `clear()`, `erase()`, `snapshot()` all delegate to its underlying `this.texture` (a DynamicTexture).
**Origin note:** RenderTexture extends Image, so its origin defaults to (0.5, 0.5). If you want top-left positioning (common for full-screen or minimap RTs), call `rt.setOrigin(0, 0)`.
### The Command Buffer (v4 Architecture)
In Phaser 4, drawing calls (`draw`, `stamp`, `fill`, `clear`, `erase`, `repeat`, `capture`) do **not** execute immediately. They push commands into a `commandBuffer` array. You must call `.render()` to flush and execute the buffer.
```js
rt.clear();
rt.fill(0x000000);
rt.draw(sprite, 128, 128);
rt.render(); // REQUIRED -- nothing appears without this
```
For RenderTexture game objects, the `renderMode` property controls automatic rendering:
| Mode | Behavior |
|---|---|
| `'render'` (default) | Draws the texture contents to the frame each tick. You call `render()` manually when content changes. |
| `'redraw'` | Calls `render()` automatically every frame but does NOT display itself. Useful for textures reused by other objects. |
| `'all'` | Calls `render()` every frame AND draws itself to the frame. |
```js
rt.setRenderMode('all'); // auto-render + display every frame
rt.setRenderMode('all', true); // same, plus preserve the command buffer
```
### Preserve Mode
By default the command buffer clears after `render()`. Call `preserve(true)` to keep commands between renders, so the same drawing replays each frame:
```js
rt.preserve(true);
rt.clear();
rt.draw(sprite);
// On every subsequent render(), clear + draw will repeat
```
### Stamp Game Object
`Stamp` (`this.add.stamp(x, y, texture, frame)`) is a lightweight Image subclass that ignores camera scroll and transform during rendering. It is used internally by DynamicTexture for drawing operations and is also useful for HUD elements. It extends Image with custom render nodes (`DefaultStampNodes`).
### The `stamp()` Method vs the Stamp Game Object
These are different things:
- **`rt.stamp(key, frame, x, y, config)`** -- a method on RenderTexture/DynamicTexture that draws a texture frame to the surface with transform options (alpha, tint, angle, scale, origin, blendMode).
- **`this.add.stamp(x, y, texture, frame)`** -- a factory that creates a Stamp game object added to the Scene display list.
## Common Patterns
### Drawing Sprites and Game Objects
```js
const rt = this.add.renderTexture(0, 0, 800, 600);
// Single game object at an offset
rt.draw(sprite, 100, 100);
// Array of objects
rt.draw([sprite1, sprite2, sprite3]);
// Group or Container (only visible children are drawn)
rt.draw(enemyGroup);
rt.draw(myContainer, 50, 50); // offset added to children positions
// Entire Scene display list
rt.draw(this.children);
// Texture by string key
rt.draw('explosion', 200, 200);
// Don't forget to flush
rt.render();
```
The `draw()` method accepts: renderable game objects, Groups, Containers, Display Lists, other RenderTextures/DynamicTextures, Texture Frames, texture key strings, or arrays of any of these.
Note: `alpha` and `tint` parameters on `draw()` only apply to Texture Frames/strings. Game objects use their own alpha and tint when drawn.
### Stamping Textures with Config
The `stamp()` method draws a texture frame with full transform control. The frame is centered on the x/y position by default (origin 0.5).
```js
rt.stamp('bullet', null, 100, 100, {
alpha: 0.8,
tint: 0xff0000,
angle: 45, // degrees (takes precedence over rotation)
scale: 2, // uniform scale
scaleX: 1.5, // overrides scale for X
scaleY: 0.5, // overrides scale for Y
originX: 0, // top-left origin
originY: 0,
blendMode: 0
});
rt.render();
```
### Capture -- Drawing with Overrides (v4)
The `capture()` method draws a game object with temporary property overrides, restoring originals afterward:
```js
rt.capture(player, {
x: 64,
y: 64,
scale: 0.5,
alpha: 0.8,
rotation: Math.PI / 4,
transform: 'world', // 'local', 'world', or a TransformMatrix
camera: someCamera // optional camera override
});
rt.render();
```
This is useful for drawing an object at a different position/scale without modifying the object itself.
### Filling and Clearing
```js
// Fill entire texture with color
rt.fill(0xff0000); // solid red
rt.fill(0x000000, 0.5); // semi-transparent black
// Fill a region
rt.fill(0x00ff00, 1, 10, 10, 100, 50); // green rect at (10,10) size 100x50
// Clear everything (transparent)
rt.clear();
// Clear a region
rt.clear(10, 10, 100, 50);
rt.render();
```
### Erasing
Erase uses ERASE blend mode to cut holes in the texture:
```js
rt.fill(0xffffff); // white background
rt.erase(circleSprite, 100, 100); // punch a hole shaped like the sprite
rt.render();
```
### Repeating / Tiling a Texture
```js
// Fill the entire RenderTexture with a tiled pattern
rt.repeat('grass', null); // tile the whole surface
rt.repeat('brick', null, 0, 0, 256, 128); // tile a specific region
rt.repeat('tile', 'frame2', 0, 0, 512, 512, {
tileScaleX: 2,
tileScaleY: 2,
tilePositionX: 16,
alpha: 0.8
});
rt.render();
```
### Snapshots (Pixel Capture)
Snapshots read pixel data from the framebuffer. They are **expensive and blocking** -- use sparingly.
```js
// Full texture snapshot -- callback receives an HTMLImageElement
rt.snapshot(function (image) {
document.body.appendChild(image); // or use as texture source
});
// Area snapshot
rt.snapshotArea(0Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.