Construct-bugs icon indicating copy to clipboard operation
Construct-bugs copied to clipboard

drawing canvas 'fixed' resolution misalignment

Open Ldwebster111 opened this issue 1 year ago • 2 comments

Problem description

When using the drawing canvas to capture graphics using the fixed resolution, it is offset by a pixel on both the horizontal and vertical.

Attach a .c3p

drawing canvas pixel error.zip

Steps to reproduce

  1. launch program. Press any mouse click to toggle drawing canvas visibility in comparison to the tiles that it has captured.

Observed result

The drawing canvas is offset by a pixel to the left and top.

Expected result

The canvas snapshot should match the pixel placements of the tiles beneath it.

More details

I first noticed an issue with drawing canvas glitches on a large scale floor canvas that was capturing decals for better perf management. On capture, there was an evident pop in the objects being saved, and at a large scale (3000x3000 layout) it wasn't always predictable that the shift would happen in the same direction despite all decals being positioned to int numbers. (edit, see post below. I believe the unpredictability of this was related to the sprites being randomly assigned mirrored/not mirrored on spawn)

More recently, I've begun using small tiles, like the sprites in the example file, to generate random levels and then capturing the composed tiles using drawing canvas and converting that pixel data into array values to build a level later on. However, I noticed that the array was not filling correctly on the first x/y axis, and after some investigation discovered this quirk with the drawing canvas.

Note, this doesn't happen in 'automatic' mode, but a minimised screen breaks level generation using this system completely and so it's important to have an accurate canvas in 'fixed' mode for this system.

Can clarify other users on C3 Discord have also experienced this. I also went through and tested it in a stable build from a year ago and it also happened in that build too.

Affected browsers/platforms:

Ldwebster111 avatar May 15 '24 11:05 Ldwebster111

The misalignment is even worse (or more noticeable) when tiles are randomly rotated at right angles:

drawing canvas pixel error

Build with rotatable tiles:

drawing canvas pixel error.zip

Ldwebster111 avatar May 15 '24 23:05 Ldwebster111

Any update on this issue? fixed resolution canvas is essentially broken for pixel games because of this.

Here's a simple project that compares fixed and automatic canvas. Not only is the last pixel stretched in fixed, the entire texture is incorrectly sized.

canvas bug

fixed canvas paste bug.zip

Ldwebster111 avatar Aug 04 '24 11:08 Ldwebster111

After looking in to #8358, the fix for that seems to have also fixed this case, so they look like they were the same problem.

AshleyScirra avatar Jan 16 '25 16:01 AshleyScirra