Trim needless comments and fix the picker width
Remove comments that only restate the code, keeping the section banners and the notes that carry a reason, a measured fact or an external contract. ButtonOptions.width claimed to be a fixed width but only set minWidth, so the Graph and Texture pickers grew with the name they showed. It is now what it promises, with a separate minWidth for the buttons that have two forms. Narrow buttons shrink their padding, otherwise a 24px icon button had 8px left for its glyph and truncate dropped it entirely. __gm.labelsDropped() guards that class: the overflow guard only saw text that was too wide, never a label truncated to nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f16801aef3
commit
4d84231b9f
115 files changed
+707
-1564
No files matched your search
+13
-33
@@ -1,13 +1,10 @@
|
||||
/**
|
||||
* The Texture tab: cutting frames out of a sheet, and a sprite wearing one.
|
||||
*
|
||||
* Runs after the texture step, whose four-quadrant 64x48 picture is what makes this checkable
|
||||
* at all – a frame over one quadrant has a colour of its own, so "which part of the sheet is
|
||||
* on screen" is a question `pixelAt` can answer. Nothing here is stubbed: the frame is made by
|
||||
* dragging on the canvas, and the sprite is read back off the rendered pixels.
|
||||
* Runs after the texture step, whose four-quadrant 64x48 picture gives every quadrant a colour
|
||||
* of its own – that is what makes "which part of the sheet is on screen" a `pixelAt` question.
|
||||
*/
|
||||
|
||||
/** How far apart two `#rrggbb` colours are, summed over the channels. */
|
||||
function colourDistance(a, b) {
|
||||
const channels = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
|
||||
const [ar, ag, ab] = channels(a);
|
||||
@@ -21,21 +18,12 @@ const PALETTE = {
|
||||
green: '#3cc85a',
|
||||
blue: '#466ef0',
|
||||
white: '#f5f5f5',
|
||||
/**
|
||||
* The sprite's own colour for the fallback check, deliberately a colour the sheet does not
|
||||
* contain. The sheet's fourth quadrant is near-white, so leaving the sprite white would make
|
||||
* "it fell back to its colour" and "it is showing that quadrant" the same measurement.
|
||||
*/
|
||||
plain: '#ff00ff',
|
||||
};
|
||||
|
||||
/**
|
||||
* Which of the known colours a sampled pixel is: the nearest one by channel distance.
|
||||
*
|
||||
* Asked this way rather than "is it exactly green" on purpose. The scene carries editor gizmos
|
||||
* by this point – a collider's fill is drawn over its body at 12 % alpha – so a sample can be
|
||||
* tinted by a few percent without anything being wrong. That shifts a colour slightly; it
|
||||
* cannot make one quadrant of the sheet read as another, which is the only question here.
|
||||
* Nearest known colour rather than an exact match: editor gizmos (a collider fill at 12 % alpha)
|
||||
* tint a sample by a few percent, which still cannot make one quadrant read as another.
|
||||
*/
|
||||
function nearestColour(sample) {
|
||||
let best = '';
|
||||
@@ -68,9 +56,8 @@ export async function frames(t) {
|
||||
);
|
||||
await shot('33-texture-tab');
|
||||
|
||||
// 21. Dragging on the picture cuts a frame. The drag is aimed at the top-right quadrant of
|
||||
// the sheet (32,0)-(64,24), inset by a pixel so the press cannot land on the edge of a
|
||||
// neighbouring frame and be read as a resize instead of a new rectangle.
|
||||
// 21. Dragging on the picture cuts a frame. Aimed at the top-right quadrant (32,0)-(64,24),
|
||||
// inset by a pixel: a press on a frame edge is read as a resize, not a new rectangle.
|
||||
const from = await json('__gm.texture.pointAt(33, 1)');
|
||||
const to = await json('__gm.texture.pointAt(63, 23)');
|
||||
check('the sheet is on screen', Boolean(from) && Boolean(to), JSON.stringify({ from, to }));
|
||||
@@ -111,11 +98,7 @@ export async function frames(t) {
|
||||
await t.redo();
|
||||
await sleep(400);
|
||||
|
||||
// 22. A sprite wearing the frame shows that part of the sheet and nothing else. This is the
|
||||
// check the whole feature exists for: the model difference between "whole picture" and
|
||||
// "this frame" is one id, so only the drawn pixels can tell them apart.
|
||||
// The sprite from the texture step is reused, white and unparented, but its texture
|
||||
// reference was left dangling there – it is pointed at the frame here.
|
||||
// 22. A sprite wearing the frame shows that part of the sheet and nothing else.
|
||||
await evaluate(`(() => {
|
||||
const sprite = __gm.state.project.assets.find((a) => a.id === 'tex-sprite');
|
||||
sprite.props.color = 0xffffff;
|
||||
@@ -132,9 +115,8 @@ export async function frames(t) {
|
||||
json(`__gm.pixelAt(${Math.round(box.x + fx * box.w)}, ${Math.round(box.y + fy * box.h)})`);
|
||||
const corners = [await at(-0.3, -0.3), await at(0.3, -0.3), await at(-0.3, 0.3), await at(0.3, 0.3)];
|
||||
const read = corners.map(nearestColour);
|
||||
// Without the frame these four corners read red / green / blue / white – that is what the
|
||||
// texture step asserts one screen earlier. Reading green four times is therefore the exact
|
||||
// statement that the fill was confined to one quadrant of the sheet.
|
||||
// Without the frame these corners read red / green / blue / white, as the texture step
|
||||
// asserts – so four greens is the statement that the fill stayed inside one quadrant.
|
||||
check(
|
||||
'the whole sprite shows the one quadrant the frame cuts out',
|
||||
read.every((c) => c === 'green'),
|
||||
@@ -143,10 +125,9 @@ export async function frames(t) {
|
||||
await shot('35-sprite-wearing-a-frame');
|
||||
}
|
||||
|
||||
// 23. Slicing offers a live count before it commits – the readout is what makes the numbers
|
||||
// answerable without undoing.
|
||||
// Repainted magenta before slicing: with the frame gone the sprite falls back to this, and
|
||||
// magenta is nowhere in the sheet, so the fallback cannot be confused with a part of it.
|
||||
// 23. Slicing offers a live count before it commits.
|
||||
// Repainted magenta first: magenta is nowhere in the sheet, so the fallback check below
|
||||
// cannot be confused with a part of the picture.
|
||||
await evaluate(`(() => {
|
||||
__gm.state.project.assets.find((a) => a.id === 'tex-sprite').props.color = 0xff00ff;
|
||||
__gm.state.preview();
|
||||
@@ -180,8 +161,7 @@ export async function frames(t) {
|
||||
check('and numbers them in reading order', sliced[0]?.startsWith('Frame 1 '), JSON.stringify(sliced[0]));
|
||||
await shot('36-sliced-sheet');
|
||||
|
||||
// 23a. The sprite pointed at the frame that slicing removed falls back to its colour rather
|
||||
// than to a wrong part of the picture.
|
||||
// 23a. A sprite pointed at a frame slicing removed falls back to its colour.
|
||||
await evaluate("__gm.showTab('scene')");
|
||||
await sleep(700);
|
||||
if (box) {
|
||||
|
||||
Reference in new issue
Block a user