Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-graphics-and-dom

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Draw Graphics/SVG shapes and sprite masks; align a DOM overlay with UI/canvas nodes. Use for overlay placement, input interception, experimental HTML textures or AirUIMesh.

  • 15 files
  • 61.1 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-graphics-and-dom

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescommon-mistakes.md

≈724 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Derived from the cocosair-graphics-and-dom skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.

Common Mistakes

[HIGH] Passing a gradient, pattern, or evenodd hole to drawAirGraphics

Wrong:

drawAirGraphics(g, [
    { op: 'rect', args: [0, 0, 200, 100] },
    { op: 'circle', args: [100, 50, 20] },
    { op: 'fill', rule: 'evenodd',
      paint: { kind: 'linear', from: [0, 0], to: [200, 0],
               stops: [{ offset: 0, color: '#ff0000' }, { offset: 1, color: '#0000ff' }] } },
]);

Correct:

const paint = rasterizeAirGraphics(commands, {
    bounds: { x: 0, y: 0, width: 200, height: 100 }, resolution: 2 });
const display = createAirTextureSprite(parent, paint.texture, { size: [200, 100] });

drawAirGraphics throws AIR_E_GRAPHICS_COMMAND on a non-solid or evenodd fill and routes gradients/patterns/holes to the raster path; native replay never silently degrades (src/air/graphics-commands.ts:76, docs/manual/graphics-and-dom.md:56, :60-86).

[HIGH] Treating masks, blend scopes, and DOM overlays as fire-and-forget

Wrong:

attachAirSpriteMask(sprite, tex);      // then swap sprite.spriteFrame or move nodes
const blend = createAirUIBlendScope(root, 'add');   // never re-applied after changes
const overlay = createAirDOMOverlay({ canvas });    // attach, then never call update()

Correct:

mask.update();               // after replacing spriteFrame on the same binding
blend.update();              // after hierarchy / component / particle / material edits
binding.update();            // from the app frame callback after camera or layout moves

mask follows the current frame's UV_UPDATED but needs an explicit update() on a frame swap; blend and overlay are controllers whose GPU/DOM state only re-syncs when you call update() (src/air/effects/sprite-mask.ts:64-67, src/air/ui-blend.ts:36-53, src/air/dom-overlay.ts:50-67). Each owns resources you must dispose() before releasing the borrowed texture, node, or element (docs/manual/graphics-and-dom.md:98, :34).

[MEDIUM] Forgetting SVG export constraints for patterns

Wrong:

airGraphicsCommandsToSvg(commands, bounds);   // pattern uses textureSpace: 'global'
// or a pattern with no sourceURL at all

Correct:

// Convert global patterns to a local transform first, and give every pattern a
// data:image or http(s) sourceURL before exporting.
const svg = airGraphicsCommandsToSvg(localCommands, bounds);

airGraphicsCommandsToSvg throws on textureSpace: 'global' and on a missing or non data:image/http(s) sourceURL; it never fetches or embeds external URLs and offers no arbitrary SVG text parser (src/air/graphics-commands.ts:106-107, docs/manual/graphics-and-dom.md:58).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Edit Write Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "draw shapes or export curves as SVG",
  "paint gradients, patterns or evenodd holes",
  "mask a sprite or inherit subtree blending",
  "keep a DOM input attached to a UI node",
  "display live HTML or warp textured UI geometry"
]
owns
[
  "graphics-svg",
  "rich-fills",
  "sprite-masks",
  "ui-blend",
  "dom-overlay",
  "html-texture"
]
not_for
[
  "UI widgets and layout -> cocosair-ui-2d",
  "keyboard focus and action routing -> cocosair-input-action",
  "general offscreen render targets -> cocosair-rendering"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "使用 Graphics、SVG、栅格填充、纹理显示、遮罩、混合和 DOM 覆盖层。用于绘图导出、富填充或实验性 HTML 纹理。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-graphics-and-dom