Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(dragonbones): the Color field on an armature does something

yhh76d2b70b6d56
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd674d737..d30ba3c05 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,17 @@ published separately; it ships inside the editor.
## [Unreleased]
+### Fixed
+
+- **A DragonBones armature ignored its Color.** The field was in the inspector and
+ did nothing — the runtime's ABI had no tint entry point, so the value was
+ authored, saved, and dropped. It tints now, and **multiplies** each slot's own
+ colour rather than replacing it, so what an artist set in DragonBones Pro
+ survives being tinted. Opaque white is the tint that changes nothing, which is
+ what makes clearing the field restore the original instead of leaving the last
+ colour stuck. Per entity, so one of two figures sharing a skeleton can be tinted
+ alone.
+
## [0.35.0] - 2026-07-28
A second skeletal runtime. Estella has animated Spine skeletons since 0.19.0;
diff --git a/docs/astro/src/content/docs/guides/dragonbones.mdx b/docs/astro/src/content/docs/guides/dragonbones.mdx
index 8328c889c..1d530952f 100644
--- a/docs/astro/src/content/docs/guides/dragonbones.mdx
+++ b/docs/astro/src/content/docs/guides/dragonbones.mdx
@@ -71,10 +71,11 @@ the link.
The armature poses **in the viewport while you edit** — changing the animation, the
scale or a flip shows immediately, without pressing Play.
-<Aside type="caution">
- `color` is authored but not yet applied to a DragonBones armature — the runtime's
- ABI has no tint entry point. Slot colours authored in DragonBones Pro *are*
- honoured; this is the per-entity tint on top of them.
+<Aside type="note">
+ `color` **multiplies** each slot's authored colour rather than replacing it, so
+ what an artist set in DragonBones Pro survives being tinted — and opaque white
+ (the default) is the tint that changes nothing, which is why clearing the field
+ restores the original instead of leaving the last colour stuck.
</Aside>
## Choosing an armature
@@ -129,8 +130,9 @@ const control = defineSystem(
| `fadeIn(entity, name, seconds, loop?)` | Crossfade into an animation. |
| `stop(entity, name?)` | Stop one animation, or all of them when omitted. |
| `setTimeScale(entity, scale)` | Per-entity playback speed. |
+| `setColor(entity, r, g, b, a)` | Tint the whole armature (0..1), multiplied onto slot colours. |
| `setEnabled(entity, on)` | Remove from the frame entirely (freeze **and** hide). |
-| `setEntityProps(entity, props)` | Set `{ skeletonScale?, flipX?, flipY?, layer?, playing?, timeScale? }` at once. |
+| `setEntityProps(entity, props)` | Set `{ skeletonScale?, flipX?, flipY?, layer?, playing?, timeScale?, color? }` at once. |
`playing: false` freezes the pose but keeps drawing it; `setEnabled(false)` takes
the armature out of the frame. They are different things and both are useful.
diff --git a/docs/astro/src/content/docs/zh-cn/guides/dragonbones.mdx b/docs/astro/src/content/docs/zh-cn/guides/dragonbones.mdx
index 959678ada..47aeb130e 100644
--- a/docs/astro/src/content/docs/zh-cn/guides/dragonbones.mdx
+++ b/docs/astro/src/content/docs/zh-cn/guides/dragonbones.mdx
@@ -61,9 +61,10 @@ DragonBones 导出的是三个文件,Estella 把它们作为同一种资源类
编辑时骨架**就在视口里摆着**——改动画、改缩放、改翻转都会立刻看到,不用按 Play。
-<Aside type="caution">
- `color` 可以填,但目前还没有作用到 DragonBones 骨架上——运行时的 ABI 没有着色入口。
- 在 DragonBones Pro 里给插槽设的颜色**是**生效的;这里说的是叠在它之上的那层每实体着色。
+<Aside type="note">
+ `color` 是**乘**在每个插槽自己的颜色上,而不是替换它——所以美术在 DragonBones Pro 里设的
+ 颜色不会因为被着色而丢失。不透明白(默认值)就是"什么都不改变"的那个着色,所以清空这个字段
+ 会还原成原样,而不是把最后一次的颜色留在那儿。
</Aside>
## 选择骨架
@@ -113,8 +114,9 @@ const control = defineSystem(
| `fadeIn(entity, name, seconds, loop?)` | 交叉淡入到一个动画。 |
| `stop(entity, name?)` | 停一个动画;省略名字则全停。 |
| `setTimeScale(entity, scale)` | 每实体的播放速度。 |
+| `setColor(entity, r, g, b, a)` | 给整个骨架着色(0..1),乘在插槽自身颜色上。 |
| `setEnabled(entity, on)` | 整个从这一帧里拿掉(既冻结**又**隐藏)。 |
-| `setEntityProps(entity, props)` | 一次设 `{ skeletonScale?, flipX?, flipY?, layer?, playing?, timeScale? }`。 |
+| `setEntityProps(entity, props)` | 一次设 `{ skeletonScale?, flipX?, flipY?, layer?, playing?, timeScale?, color? }`。 |
`playing: false` 是冻住姿势但继续画;`setEnabled(false)` 是把骨架从这一帧里拿掉。这是两件事,
而且两个都有用。
diff --git a/sdk/etc/dragonbones.api.md b/sdk/etc/dragonbones.api.md
index eb2b66e38..3dde489d4 100644
--- a/sdk/etc/dragonbones.api.md
+++ b/sdk/etc/dragonbones.api.md
@@ -47,8 +47,9 @@ loadSkeleton: (skeletonData: Uint8Array | string, atlasJson: string, assetKey?:
play: (entity: Entity, animation: string, loop?: boolean) => boolean
removeEntity: (entity: Entity) => void
setAtlasTexture: (skeletonHandle: number, textureId: number) => void
+setColor: (entity: Entity, r: number, g: number, b: number, a: number) => void
setEnabled: (entity: Entity, enabled: boolean) => void
-setEntityProps: (entity: Entity, props: Partial<Pick<EntityInfo, "skeletonScale" | "flipX" | "flipY" | "layer" | "playing">> & { timeScale?: number; }) => void
+setEntityProps: (entity: Entity, props: Partial<Pick<EntityInfo, "skeletonScale" | "flipX" | "flipY" | "layer" | "playing">> & { timeScale?: number; color?: { r: number; g: number; b: number; a: number; }; }) => void
setTimeScale: (entity: Entity, scale: number) => void
stop: (entity: Entity, animation?: string) => void
submitMeshes: (core: SkeletalSubmitCore, registry: unknown) => void
@@ -72,6 +73,7 @@ loadSkeleton: (skeletonData: Uint8Array | string, atlasJson: string) => number
play: (instanceId: number, animation: string, loop?: boolean) => boolean
runtimeVersion: () => number
setAtlasTexture: (handle: number, textureId: number) => void
+setColor: (instanceId: number, r: number, g: number, b: number, a: number) => void
setTimeScale: (instanceId: number, scale: number) => void
stop: (instanceId: number, animation?: string) => void
unloadSkeleton: (handle: number) => void
@@ -125,6 +127,7 @@ loadSkeleton: (skeletonPtr: number, skeletonLen: number, atlasPtr: number, atlas
playAnimation: (instanceId: number, name: string, playTimes: number) => number
runtimeVersion: () => number
setAtlasTexture: (handle: number, textureId: number) => void
+setColor: (instanceId: number, r: number, g: number, b: number, a: number) => void
setTimeScale: (instanceId: number, scale: number) => void
stopAnimation: (instanceId: number, name: string) => void
unloadSkeleton: (handle: number) => void
@@ -147,7 +150,7 @@ resolveRef: ((ref: string) => string) | undefined
## dragonBonesEntityProps — function
```
-(d: Record<string, unknown>): { skeletonScale: number; flipX: boolean; flipY: boolean; layer: number; timeScale: number; playing: boolean; }
+(d: Record<string, unknown>): { skeletonScale: number; flipX: boolean; flipY: boolean; layer: number; timeScale: number; playing: boolean; color: { r: number; g: number; b: number; a: number; }; }
```
## dragonBonesPlugin — const
diff --git a/sdk/src/dragonbones/DragonBonesController.ts b/sdk/src/dragonbones/DragonBonesController.ts
index 04f75322b..94ff6b59f 100644
--- a/sdk/src/dragonbones/DragonBonesController.ts
+++ b/sdk/src/dragonbones/DragonBonesController.ts
@@ -122,6 +122,11 @@ export class DragonBonesModuleController implements SkeletalController {
this.api_.setTimeScale(instanceId, scale);
}
+ /** Tint, multiplied onto each slot's authored colour — opaque white is "as drawn". */
+ setColor(instanceId: number, r: number, g: number, b: number, a: number): void {
+ this.api_.setColor(instanceId, r, g, b, a);
+ }
+
update(instanceId: number, dt: number): void {
this.api_.update(instanceId, dt);
}
diff --git a/sdk/src/dragonbones/DragonBonesManager.ts b/sdk/src/dragonbones/DragonBonesManager.ts
index e66755f35..0bfc9858b 100644
--- a/sdk/src/dragonbones/DragonBonesManager.ts
+++ b/sdk/src/dragonbones/DragonBonesManager.ts
@@ -148,15 +148,27 @@ export class DragonBonesManager {
setEntityProps(
entity: Entity,
props: Partial<Pick<EntityInfo, 'skeletonScale' | 'flipX' | 'flipY' | 'layer' | 'playing'>>
- & { timeScale?: number },
+ & { timeScale?: number; color?: { r: number; g: number; b: number; a: number } },
): void {
const info = this.entities_.get(entity);
if (!info) return;
- const { timeScale, ...rest } = props;
+ const { timeScale, color, ...rest } = props;
Object.assign(info, rest);
- // timeScale is not a field to assign: the module owns the clock, so it has
- // to be told rather than remembered.
+ // Neither of these is a field to assign: the module owns the clock and the
+ // tint, so it has to be told rather than remembered.
if (timeScale !== undefined) this.setTimeScale(entity, timeScale);
+ if (color) this.setColor(entity, color.r, color.g, color.b, color.a);
+ }
+
+ /**
+ * Tint the whole armature. Multiplied onto each slot's authored colour, so
+ * opaque white is not "no tint applied" but "the tint that changes nothing" —
+ * which is why clearing the field in the editor restores the original rather
+ * than leaving the last colour stuck.
+ */
+ setColor(entity: Entity, r: number, g: number, b: number, a: number): void {
+ const info = this.entities_.get(entity);
+ if (info) this.controller_.setColor(info.instanceId, r, g, b, a);
}
// — Animation ————————————————————————————————————————————————————————————
diff --git a/sdk/src/dragonbones/DragonBonesModuleLoader.ts b/sdk/src/dragonbones/DragonBonesModuleLoader.ts
index 40f8d3f2e..adee68053 100644
--- a/sdk/src/dragonbones/DragonBonesModuleLoader.ts
+++ b/sdk/src/dragonbones/DragonBonesModuleLoader.ts
@@ -30,6 +30,7 @@ export interface DragonBonesWrappedAPI {
fadeInAnimation(instanceId: number, name: string, fadeSeconds: number, playTimes: number): number;
stopAnimation(instanceId: number, name: string): void;
setTimeScale(instanceId: number, scale: number): void;
+ setColor(instanceId: number, r: number, g: number, b: number, a: number): void;
update(instanceId: number, dt: number): void;
getAnimations(instanceId: number): string;
@@ -67,6 +68,7 @@ export function wrapDragonBonesModule(raw: DragonBonesWasmModule): DragonBonesWr
fadeInAnimation: w('fadeInAnimation', N, [N, S, N, N]),
stopAnimation: w('stopAnimation', null, [N, S]),
setTimeScale: w('setTimeScale', null, [N, N]),
+ setColor: w('setColor', null, [N, N, N, N, N]),
update: w('update', null, [N, N]),
getAnimations: w('getAnimations', S, [N]),
diff --git a/sdk/src/dragonbones/loadDragonBonesScene.ts b/sdk/src/dragonbones/loadDragonBonesScene.ts
index 8016dbeff..f00f17ef3 100644
--- a/sdk/src/dragonbones/loadDragonBonesScene.ts
+++ b/sdk/src/dragonbones/loadDragonBonesScene.ts
@@ -45,8 +45,10 @@ export type TranscoderProvider = () => Promise<BasisTranscoder | null>;
export function dragonBonesEntityProps(d: Record<string, unknown>): {
skeletonScale: number; flipX: boolean; flipY: boolean; layer: number;
timeScale: number; playing: boolean;
+ color: { r: number; g: number; b: number; a: number };
} {
const num = (v: unknown, dflt: number): number => (typeof v === 'number' ? v : dflt);
+ const color = d.color;
return {
skeletonScale: num(d.skeletonScale, 1),
flipX: d.flipX === true,
@@ -54,6 +56,12 @@ export function dragonBonesEntityProps(d: Record<string, unknown>): {
layer: num(d.layer, 0),
timeScale: num(d.timeScale, 1),
playing: d.playing !== false,
+ // Opaque white rather than undefined, so CLEARING the field in the editor
+ // resets the tint instead of leaving the last colour applied (setEntityProps
+ // only writes a colour it was given). Same reasoning as spineEntityProps.
+ color: color && typeof color === 'object'
+ ? (color as { r: number; g: number; b: number; a: number })
+ : { r: 1, g: 1, b: 1, a: 1 },
};
}
diff --git a/sdk/tests/dragonbones-load.integration.test.ts b/sdk/tests/dragonbones-load.integration.test.ts
index 7da20b932..4cb296ae8 100644
--- a/sdk/tests/dragonbones-load.integration.test.ts
+++ b/sdk/tests/dragonbones-load.integration.test.ts
@@ -144,6 +144,110 @@ describe.skipIf(!HAS_ASSETS)('DragonBones side module', () => {
call('db_unloadSkeleton', null, ['number'], [handle]);
});
+ it('tints the armature, multiplying rather than replacing the authored colour', () => {
+ const handle = load();
+ call('db_setAtlasTexture', null, ['number', 'number'], [handle, 7]);
+ const instance = call<number>('db_createInstance', 'number', ['number', 'string'], [handle, 'Dragon']);
+ call('db_playAnimation', 'number', ['number', 'string', 'number'], [instance, 'stand', 0]);
+ call('db_update', null, ['number', 'number'], [instance, 1 / 60]);
+
+ /// Every vertex's RGBA from batch 0. getMeshBatchCount is what re-poses into
+ /// the shared batch list — the other getters read that snapshot — so asking
+ /// for it is how a reader says which instance it means.
+ const colours = (): { r: number; g: number; b: number; a: number }[] => {
+ call('db_getMeshBatchCount', 'number', ['number'], [instance]);
+ const vertexCount = call<number>('db_getMeshBatchVertexCount', 'number', ['number', 'number'], [instance, 0]);
+ const indexCount = call<number>('db_getMeshBatchIndexCount', 'number', ['number', 'number'], [instance, 0]);
+ const vp = M._malloc(vertexCount * 8 * 4);
+ const ip = M._malloc(indexCount * 2);
+ const tp = M._malloc(4);
+ const bp = M._malloc(4);
+ call('db_getMeshBatchData', null, ['number', 'number', 'number', 'number', 'number', 'number'], [
+ instance, 0, vp, ip, tp, bp,
+ ]);
+ const v = new Float32Array(M.HEAPF32.buffer, vp, vertexCount * 8);
+ const out = [];
+ for (let i = 0; i < vertexCount; i++) {
+ out.push({ r: v[i * 8 + 4], g: v[i * 8 + 5], b: v[i * 8 + 6], a: v[i * 8 + 7] });
+ }
+ M._free(vp); M._free(ip); M._free(tp); M._free(bp);
+ return out;
+ };
+
+ // Untinted is the identity: whatever the file authored, unchanged.
+ const authored = colours();
+ expect(authored.length).toBeGreaterThan(0);
+
+ // Half red, half alpha. Each channel scales by its own factor, which a
+ // replace-instead-of-multiply implementation could not produce.
+ call('db_setColor', null, ['number', 'number', 'number', 'number', 'number'], [instance, 0.5, 1, 1, 0.5]);
+ call('db_update', null, ['number', 'number'], [instance, 1 / 60]);
+ const tinted = colours();
+ expect(tinted.length).toBe(authored.length);
+ for (let i = 0; i < authored.length; i++) {
+ expect(tinted[i].r).toBeCloseTo(authored[i].r * 0.5, 5);
+ expect(tinted[i].g).toBeCloseTo(authored[i].g, 5);
+ expect(tinted[i].b).toBeCloseTo(authored[i].b, 5);
+ expect(tinted[i].a).toBeCloseTo(authored[i].a * 0.5, 5);
+ }
+
+ // And white puts it back, which is what clearing the field must do.
+ call('db_setColor', null, ['number', 'number', 'number', 'number', 'number'], [instance, 1, 1, 1, 1]);
+ call('db_update', null, ['number', 'number'], [instance, 1 / 60]);
+ const restored = colours();
+ for (let i = 0; i < authored.length; i++) {
+ expect(restored[i].r).toBeCloseTo(authored[i].r, 5);
+ expect(restored[i].a).toBeCloseTo(authored[i].a, 5);
+ }
+
+ call('db_destroyInstance', null, ['number'], [instance]);
+ call('db_unloadSkeleton', null, ['number'], [handle]);
+ });
+
+ it('tints one instance without touching another sharing the skeleton', () => {
+ // The tint lives per instance, not on the shared skeleton — two entities of
+ // one file are the whole reason the sharing exists.
+ const handle = load();
+ call('db_setAtlasTexture', null, ['number', 'number'], [handle, 7]);
+ const a = call<number>('db_createInstance', 'number', ['number', 'string'], [handle, 'Dragon']);
+ const b = call<number>('db_createInstance', 'number', ['number', 'string'], [handle, 'Dragon']);
+ for (const id of [a, b]) {
+ call('db_playAnimation', 'number', ['number', 'string', 'number'], [id, 'stand', 0]);
+ call('db_update', null, ['number', 'number'], [id, 1 / 60]);
+ }
+
+ const firstAlpha = (id: number): number => {
+ call('db_getMeshBatchCount', 'number', ['number'], [id]); // pose THIS instance
+ // Sized from what the batch actually holds — a fixed guess is a buffer
+ // db_getMeshBatchData writes straight past.
+ const vertexCount = call<number>('db_getMeshBatchVertexCount', 'number', ['number', 'number'], [id, 0]);
+ const indexCount = call<number>('db_getMeshBatchIndexCount', 'number', ['number', 'number'], [id, 0]);
+ const vp = M._malloc(vertexCount * 8 * 4);
+ const ip = M._malloc(indexCount * 2);
+ const tp = M._malloc(4);
+ const bp = M._malloc(4);
+ call('db_getMeshBatchData', null, ['number', 'number', 'number', 'number', 'number', 'number'], [
+ id, 0, vp, ip, tp, bp,
+ ]);
+ const alpha = new Float32Array(M.HEAPF32.buffer, vp, 8)[7];
+ M._free(vp); M._free(ip); M._free(tp); M._free(bp);
+ return alpha;
+ };
+
+ call('db_setColor', null, ['number', 'number', 'number', 'number', 'number'], [a, 1, 1, 1, 0.25]);
+ call('db_update', null, ['number', 'number'], [a, 1 / 60]);
+ const tintedA = firstAlpha(a);
+ call('db_update', null, ['number', 'number'], [b, 1 / 60]);
+ const untouchedB = firstAlpha(b);
+
+ expect(tintedA).toBeLessThan(untouchedB);
+ expect(untouchedB).toBeCloseTo(1, 5);
+
+ call('db_destroyInstance', null, ['number'], [a]);
+ call('db_destroyInstance', null, ['number'], [b]);
+ call('db_unloadSkeleton', null, ['number'], [handle]);
+ });
+
it('survives an animation being retired — a crossfade, then the state going away', () => {
// The runtime hands a finished animation state back through
// `_armature->_dragonBones->bufferObject(state)`, and BaseFactory leaves
diff --git a/src/esengine/bindings/DragonBonesAdapter.cpp b/src/esengine/bindings/DragonBonesAdapter.cpp
index eaa4cc339..ebe693963 100644
--- a/src/esengine/bindings/DragonBonesAdapter.cpp
+++ b/src/esengine/bindings/DragonBonesAdapter.cpp
@@ -158,7 +158,7 @@ void EsSlot::_updateMesh() {
}
}
-void EsSlot::emit(es::skeletal::TriangleSink& sink, float alpha) const {
+void EsSlot::emit(es::skeletal::TriangleSink& sink, const float tint[4]) const {
if (indices.empty() || textureId == 0 || !_visible) return;
const std::size_t vertexCount = positions.size() / 2;
@@ -189,11 +189,14 @@ void EsSlot::emit(es::skeletal::TriangleSink& sink, float alpha) const {
world[i * 2 + 1] = -world[i * 2 + 1];
}
+ // The slot's authored colour and the entity's tint multiply. Replacing rather
+ // than multiplying would throw away what the artist set in DragonBones Pro the
+ // moment a game tinted anything.
const float rgba[4] = {
- _colorTransform.redMultiplier,
- _colorTransform.greenMultiplier,
- _colorTransform.blueMultiplier,
- _colorTransform.alphaMultiplier * alpha,
+ _colorTransform.redMultiplier * tint[0],
+ _colorTransform.greenMultiplier * tint[1],
+ _colorTransform.blueMultiplier * tint[2],
+ _colorTransform.alphaMultiplier * tint[3],
};
sink.emit(world.data(), uvs.data(), static_cast<int>(vertexCount), indices.data(),
static_cast<int>(indices.size()), textureId, static_cast<int>(_blendMode), rgba);
diff --git a/src/esengine/bindings/DragonBonesAdapter.hpp b/src/esengine/bindings/DragonBonesAdapter.hpp
index 76a377a58..0289a56af 100644
--- a/src/esengine/bindings/DragonBonesAdapter.hpp
+++ b/src/esengine/bindings/DragonBonesAdapter.hpp
@@ -109,7 +109,10 @@ public:
}
/// Pour this slot's triangles into `sink`, applying its transform if it owes one.
- void emit(es::skeletal::TriangleSink& sink, float alpha) const;
+ /// @param tint RGBA multiplied onto the slot's own colour — the per-entity
+ /// tint on top of what was authored in DragonBones Pro, not
+ /// instead of it.
+ void emit(es::skeletal::TriangleSink& sink, const float tint[4]) const;
protected:
// — Scene-graph duties this module does not have —
diff --git a/src/esengine/bindings/DragonBonesBindings.hpp b/src/esengine/bindings/DragonBonesBindings.hpp
index b10eb4e36..12997c0a1 100644
--- a/src/esengine/bindings/DragonBonesBindings.hpp
+++ b/src/esengine/bindings/DragonBonesBindings.hpp
@@ -46,6 +46,8 @@ int db_playAnimation(int instanceId, const char* name, int playTimes);
int db_fadeInAnimation(int instanceId, const char* name, float fadeSeconds, int playTimes);
void db_stopAnimation(int instanceId, const char* name);
void db_setTimeScale(int instanceId, float scale);
+/** Per-entity tint, multiplied onto each slot's authored colour (1,1,1,1 = as drawn). */
+void db_setColor(int instanceId, float r, float g, float b, float a);
void db_update(int instanceId, float dt);
const char* db_getAnimations(int instanceId);
diff --git a/src/esengine/bindings/DragonBonesModuleEntry.cpp b/src/esengine/bindings/DragonBonesModuleEntry.cpp
index 0a84b94ed..93287c589 100644
--- a/src/esengine/bindings/DragonBonesModuleEntry.cpp
+++ b/src/esengine/bindings/DragonBonesModuleEntry.cpp
@@ -64,6 +64,9 @@ struct LoadedSkeleton {
struct LiveInstance {
Armature* armature = nullptr;
int skeletonHandle = -1;
+ /// Per-entity tint, multiplied onto every slot's own colour. Opaque white is
+ /// the identity, so an instance nobody tints looks exactly as authored.
+ float tint[4] = {1.0f, 1.0f, 1.0f, 1.0f};
};
struct Context {
@@ -95,12 +98,12 @@ std::string skeletonName(int handle) { return "es_db_" + std::to_string(handle);
*/
void extractBatches(int instanceId) {
g_ctx.batches.clear();
- auto* armature = g_ctx.armatureOf(instanceId);
- if (!armature) return;
+ auto* live = g_ctx.instances.find(instanceId);
+ if (!live || !live->armature) return;
es::skeletal::BatchCollector collector(g_ctx.batches);
- for (auto* slot : armature->getSlots()) {
- static_cast<EsSlot*>(slot)->emit(collector, 1.0f);
+ for (auto* slot : live->armature->getSlots()) {
+ static_cast<EsSlot*>(slot)->emit(collector, live->tint);
}
}
@@ -262,6 +265,18 @@ void db_setTimeScale(int instanceId, float scale) {
if (armature) armature->getAnimation()->timeScale = scale;
}
+/// Tint this instance. Multiplied onto each slot's authored colour, so opaque
+/// white leaves the armature exactly as it was drawn.
+EMSCRIPTEN_KEEPALIVE
+void db_setColor(int instanceId, float r, float g, float b, float a) {
+ auto* live = g_ctx.instances.find(instanceId);
+ if (!live) return;
+ live->tint[0] = r;
+ live->tint[1] = g;
+ live->tint[2] = b;
+ live->tint[3] = a;
+}
+
EMSCRIPTEN_KEEPALIVE
void db_update(int instanceId, float dt) {
auto* armature = g_ctx.armatureOf(instanceId);