ODDSPRIG WEAPON GENERATOR 0.1 — AGENT GUIDE Page: /tools/2d-asset-studio/weapons/ (back to Asset Studio: ../) Everything runs in the page. No network, accounts or AI services. After the page loads, use window.oddsprigWeaponStudio. Every call updates the visible controls and preview exactly as a person using the page would. METHODS describe() Types (with the controls each type uses), styles, materials, colour keys, all control ranges, limits, lock names and export formats. getState() {version, recipe, meta, gemMode:'auto'|'custom', locks, pngSize, batch:[{index,seed,recipe}], selectedBatch}. No SVG text (use getSVG()). setRecipe(recipe) Normalizes and loads a recipe. Returns {recipe, meta}. Unknown fields are dropped, numbers clamped, bad values replaced by the type's defaults. randomize(seed, options) seed: whole number 0..4294967295, or omit/null for a new random seed. options omitted: the page's lock checkboxes apply. options object: {type?, style?, material?, colors?:{metal?,edge?,grip?,accent?,gem?}}. Each given field is kept fixed; everything else comes from the seed. The same seed and options always give the same recipe. Returns {recipe, meta}. generateBatch(count) count 1..12. Candidate i uses seed (current seed + i) and the page's locks. Returns [{index, seed, recipe, meta}]. The current weapon is NOT replaced; load a candidate with setRecipe(candidates[i].recipe). getSVG() Current editable SVG string (viewBox 0 0 512 512, transparent background). exportAsset(format, {size, download}) -> Promise format: 'svg' | 'png' | 'recipe' | 'sheet'. size: 256 | 512 | 1024 for PNG and sheet cells (default: page PNG size, 512). download: true by default (saves a file); pass false to only get data. svg/recipe -> {format, filename, mimeType, text} (recipe also has .recipe) png -> {format, filename, mimeType, size, bytes, dataUrl} sheet -> {format, png:{filename, dataUrl, bytes}, json:{filename, text, data}} The sheet holds the current weapon first, then any batch candidates, 4 per row. Its JSON lists each frame's x, y, width, height, grip/tip anchors (sheet pixels and frame-local pixels), bounds, part ids and full recipe. RECIPE (schemaVersion 1) {schemaVersion:1, type, seed, style, material, mirror, rotation, scale, colors:{metal, edge, grip, accent, gem}, params:{...}, gemPoints?:[...]} type: sword greatsword dagger katana axe hammer mace spear staff wand bow crossbow arrow pistol revolver rifle shotgun shield style: clean pixel ink ornate material: steel gold obsidian wood crystal rotation -180..180 degrees, scale 0.5..1.2, mirror true/false. Colours: six-digit hex like "#c9a043". params depend on type; describe().types[i].controls lists them with ranges. Common: ornament 0..1, wear 0..1, outlineWidth 0..6, gemCount 0..8 (integer), gemSize 3..26, gemSpread 0..80, gemPosition -50..100. gemPoints: up to 8 {x 0..512, y 0..512, size 3..26, color}. Canvas pixels. When present they replace the automatic gems; remove the field (or pass an empty list) to return to automatic gems. The page fits custom gem positions inside a safe canvas inset so the full stone remains visible. getState().recipe reports the fitted coordinates. LOCKS (page checkboxes, used by Randomize, From seed and Batch) type, palette (all five colours), style, material. LIMITS Recipe import: JSON file up to 64 KiB; it is normalized, never executed. Recovery copy: the page keeps the last recipe in localStorage key oddsprig.weapons.v1 only. USING THE ART IN ASSET STUDIO Export SVG and import it in the parent Asset Studio to draw over or animate it. Parts are named groups such as blade, guard, grip, pommel, body, string and gem-N. meta.grip and meta.tip are attachment points on the 512 canvas. EXAMPLE const s = window.oddsprigWeaponStudio; s.randomize(4242, {type: 'axe', material: 'gold'}); const r = s.getState().recipe; r.params.headSize = 110; r.rotation = -30; s.setRecipe(r); const batch = s.generateBatch(6); s.setRecipe(batch[2].recipe); const png = await s.exportAsset('png', {size: 1024, download: false}); // png.dataUrl is a transparent 1024x1024 PNG.