Clamp glass, lens and flash numbers, and restrict music.src, in normalize()
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
Research direction
Read web/engine/storyboard.mjs around the generic number clamp and music source handling, then inspect the inspector inputs in web/app.mjs and the mentioned layer renderers. Add the normalization case to test/core.test.mjs and run npm test. Done means values are clamped, external music URLs are dropped while /library/audio/ sources remain, and the Motion inputs have matching min and max attributes.
Written by the indexing model from the issue text.
Description
normalizeLayer() clamps every numeric default to ±1e12, so layer-specific limits are never enforced:
normalize({ scenes: [{ layers: [{ type: 'glass', size: -2, zoom: 0 }, { type: 'lens', size: -1 }, { type: 'flash', strength: 50 }] }] })
// glass size -2, zoom 0; lens size -1; flash strength 50 — all kept
A negative size matters. In lens() it gives a negative radius to roundRect, and in glass() it gives negative radii to ellipse. The canvas spec makes both of those throw (RangeError and IndexSizeError). The throw escapes renderer.draw() inside tick() before requestAnimationFrame(tick) is re-queued, so the preview stops. A zoom of 0 divides by zero in the glass refraction drawImage.
These values can come from a director model, an imported .json, or the Motion tab. Its Size, Zoom and Strength inputs are plain number() fields with no min or max.
There is a related gap in the same function. Image sources go through librarySrc(), which only allows /library/ and data:image/. music.src accepts any string, so an imported project can make the export fetch() an arbitrary URL.
Task:
- clamp the per-type fields: glass
size0.05–1 andzoom1–3, lenssize0.05–1, flashstrength0–1 (or whatever ranges look right in the preview) - pass matching
minandmaxto the inspector inputs - only accept
music.srcvalues under/library/audio/ - add a test to
test/core.test.mjsthat normalizes the bad values above
Where: web/engine/storyboard.mjs:61 (generic number clamp), web/engine/storyboard.mjs:113 (music); web/engine/layers.mjs:387-399 (lens), web/engine/layers.mjs:403-438 (glass); web/app.mjs:389-390 (inspector number fields), web/app.mjs:115-125 (tick).
Done when: a new test in test/core.test.mjs passes under npm test: normalizing the storyboard above gives glass/lens size > 0, glass zoom ≥ 1 and flash strength ≤ 1, a music.src of https://example.com/a.mp3 is dropped while /library/audio/... is kept; the Motion-tab Size, Zoom and Strength inputs carry matching min/max attributes.
Getting started: Node 22, no npm install needed: git clone, then npm test and npm run check. Comment here to claim it. Questions → Discord.
- Dominant language
- JavaScript
- Stars
- 42
- Forks
- 6
- Avg merge
- 12h 31m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from blixvip/GenMotion
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
accessibility good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 91/100
All issues in blixvip/GenMotion
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
scratchfoundation/scratch-editor#754 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 96/100
google/site-kit-wp#14102 ·
Maintainers usually reply within 2 days
-
area:growth priority:P1 type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
tecnologiasantos/bogoboom#66 ·
Maintainers usually reply within 1 day
-
desktop docs good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
npm/write-file-atomic#245 ·