Skip to content

Split size into separate width and height values#270

Draft
vesper-arch wants to merge 2 commits into
ptrlrd:mainfrom
vesper-arch:main
Draft

Split size into separate width and height values#270
vesper-arch wants to merge 2 commits into
ptrlrd:mainfrom
vesper-arch:main

Conversation

@vesper-arch
Copy link
Copy Markdown

First attempt at splitting these up, may be missing some changes and I've marked a couple places where I still need to do work. I do not know how to test this, so if this could be reviewed that would be great, thank you!

Copy link
Copy Markdown
Owner

@ptrlrd ptrlrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fully look into this tomorrow, but I see a few areas that can be improved.

Like gl.viewport(0, 0, outputWidth, outputWidth) the second bar should be outputHeight.

I'll do a full review tomorrow. It's super close though


function renderSlotBySlot(skeleton, renderSize, scale, cx, cy) {
const compPixels = new Uint8ClampedArray(renderSize * renderSize * 4);
function renderSlotBySlot(skeleton, renderWidth, renderHeight, scale, cx, cy) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 64 is returning 5 args but this has 6 args.

Renderheigth will returned undefined.

);

gl.viewport(0, 0, outputSize, outputSize);
gl.viewport(0, 0, outputWidth, outputWidth);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be a copy/paste error, second arg should be outputHeight

for (let y = 0; y < outputSize; y++) {
flipped.set(pixels.subarray((outputSize - 1 - y) * rowSize, (outputSize - y) * rowSize), y * rowSize);
const rowSize = outputWidth * 4;
for (let y = 0; y < outputWidth; y++) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and line R221 should be outputHeight, I think you're flipping y loop here?

}

if (bufferOk && nonTransparent > renderSize * renderSize * 0.01) {
if (bufferOk && nonTransparent > renderWidth * renderWidth * 0.01 && nonTransparent > renderHeight * renderHeight * 0.01) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be simplified to just nonTransparent >
renderWidth * renderHeight * 0.01 instead of squaring everything

const sh = maxY - minY;
const padding = outputSize * 0.05;
const avail = outputSize - padding * 2;
// TODO: Generalize this.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the generalization could prob just be

Math.min(RENDER_WIDTH, RENDER_HEIGHT)

  • PADDING * 2

const skelDir = path.resolve(process.argv[2] || "");
const outputPath = path.resolve(process.argv[3] || "output.gif");
const outputSize = parseInt(process.argv[4] || "256");
const outputWidth = parseInt(process.argv[4] || "256");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This halves it, try *2ing it? same with r57

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if people do node render_gif.mjs

512 they'll get width 512 and height 256 i think

maybe try parseInt(process.argv[5] ||
process.argv[4] || "256")

Copy link
Copy Markdown
Owner

@ptrlrd ptrlrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think this is the right way to go. It makes the tool more flexible.

I think testing strategy to see your outcome would be:

  • Regenerate a render with default square size and diff against a pre-pr output. If there's nno pixel diff then there's no regression
  • Render same skel with a non-square dem and visually confirm that the render sits inside the overlay

Feel free to make the changes + test and let me know, I can rereview.

@ptrlrd
Copy link
Copy Markdown
Owner

ptrlrd commented May 17, 2026

Overall, almost there. Width x height is missing in some areas :] thanks for contributing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants