Zoom In/Out #37

Closed
opened 2021-07-13 05:42:31 +00:00 by kirsle · 0 comments

This feature's been challenging and chipped away at slowly over time.

Zooming In and Out in the level editor involves a lot of moving parts:

  • Wallpaper scaling
  • Level Chunker scaling
    • Taking each level chunk's cached PNG texture, and blotting them on screen appropriately.
  • Translating the mouse cursor over the canvas into a world coordinate in the level while zoomed.
  • Scrolling while zoomed, and chunk loading/unloading logic about zoom
  • Actor scaling (doodads dropped on your level)
  • Drawing onto the level while zoomed
  • Link lines drawn between doodads needs to understand their change in position

Current Outstanding Issues

Scrolling into negative level coordinates

Fixed in 21520e71e9

From the default scroll position at 0,0 if you zoom Out a level, all the level to the right and below are visible at once.

As you scroll Left or Up into negative world coordinates, you'd expect the level chunks directly to the left of what was visible to appear. But you need to scroll much further left before chunks for negative level coordinates begin appearing.

It likely may need some inverted behavior when calling ZoomMultiply() on the chunk coordinate.

Can not draw reliably while zoomed

Fixed in ecdfc46358

When zoomed in or out, coordinates don't translate properly when you attempt to draw new pixels onto the level. The current user experience is:

  • You click and drag some pixels and all looks good and normal on screen, pixels stay where you left them.
  • You let go of the mouse to commit your stroke to level, and it "jumps" somewhere else that isn't where your cursor on screen was drawing.

It seems to be a miscalculation somewhere, the WorldIndexAt() fix in 37f6177a17 may help: it can now accurately map an on-screen mouse cursor position to a world index while zoomed.

Creeping Disappearing Chunks

Fixed in fd730483b0

The default chunk size in levels is 128x128 pixels.

When you zoom the level up two times (200% zoom), each of those chunks displays as 256x256 pixels on screen. As you begin scrolling right or down, all is good until you reach 128 pixels in either direction.

At 128 pixels down, the whole top row of chunks unloads; given the Viewport scroll position was 128 and it asked for level chunks within Y=128, and the chunk at (0,0) ended at Y=127, it doesn't get this chunk coordinate to loop over. The chunk wasn't in the viewport per world coordinates, though half of its image was still visible on screen.

Solutions tried:

  • Subtract from the X,Y of the viewport to load "buffer room" along the top/left edges, so e.g. when real X=128 the buffer would look from X=0 (-128) so that the (0,0) chunk ranging from (0,0,127,127) would be yielded by the chunk iterator and be sure its texture gets drawn on screen. Did not seem to help.

Actors do not scale

Fixed in 0a8bce708e

When zoomed in or out, actors remain visually on-screen in exactly the same spot they were, they do not change with the level.

It should need:

  • Passing the parent Canvas.Zoom level on to child Canvas's so they upscale their drawing the same amount.
  • And also fixing the X,Y position of the actor so they move relative to the level on zoom.
  • And also resizing the W,H of the actor Canvas widget to fit the zoomed size (easy part).

Lowest priority of all the issues.

Fixed in fd730483b0

As the doodads in the level move position and size during zoom, the pink lines connecting linked doodads together don't move at all. They still point to positions on screen where doodads would have been without zooming.

Fixed in fd730483b0

When the Actor Tool or Link Tool is selected, actors in your level should outline in orange or pink on mouse hover. This was not scaling up correctly when zoomed in.

If scrolled to 0,0 (default) all was fine when zoomed, but as the level scrolled the hitboxes would drift apart.

This feature's been challenging and chipped away at slowly over time. Zooming In and Out in the level editor involves a lot of moving parts: * Wallpaper scaling * Level Chunker scaling * Taking each level chunk's cached PNG texture, and blotting them on screen appropriately. * Translating the mouse cursor over the canvas into a world coordinate in the level while zoomed. * Scrolling while zoomed, and chunk loading/unloading logic about zoom * Actor scaling (doodads dropped on your level) * Drawing onto the level while zoomed * Link lines drawn between doodads needs to understand their change in position ## Current Outstanding Issues ### ~~Scrolling into negative level coordinates~~ > Fixed in 21520e71e953596441eedc670d0d7bee706392c5 From the default scroll position at 0,0 if you zoom Out a level, all the level to the right and below are visible at once. As you scroll Left or Up into negative world coordinates, you'd expect the level chunks directly to the left of what was visible to appear. But you need to scroll much further left before chunks for negative level coordinates begin appearing. It likely may need some inverted behavior when calling ZoomMultiply() on the chunk coordinate. ### ~~Can not draw reliably while zoomed~~ > Fixed in ecdfc46358f214c911e389cef0db3af072897f4f When zoomed in or out, coordinates don't translate properly when you attempt to draw new pixels onto the level. The current user experience is: * You click and drag some pixels and all looks good and normal on screen, pixels stay where you left them. * You let go of the mouse to commit your stroke to level, and it "jumps" somewhere else that isn't where your cursor on screen was drawing. It seems to be a miscalculation somewhere, the WorldIndexAt() fix in 37f6177a175f9de4a6831a51fb1eb8ce8c3785f2 may help: it can now accurately map an on-screen mouse cursor position to a world index while zoomed. ### ~~Creeping Disappearing Chunks~~ > Fixed in fd730483b0cfeb8051584a25873184639c509c33 The default chunk size in levels is 128x128 pixels. When you zoom the level up two times (200% zoom), each of those chunks displays as 256x256 pixels on screen. As you begin scrolling right or down, all is good until you reach 128 pixels in either direction. At 128 pixels down, the whole top row of chunks unloads; given the Viewport scroll position was 128 and it asked for level chunks within Y=128, and the chunk at (0,0) ended at Y=127, it doesn't get this chunk coordinate to loop over. The chunk wasn't in the viewport per world coordinates, though half of its image was still visible on screen. Solutions tried: * Subtract from the X,Y of the viewport to load "buffer room" along the top/left edges, so e.g. when real X=128 the buffer would look from X=0 (-128) so that the (0,0) chunk ranging from (0,0,127,127) would be yielded by the chunk iterator and be sure its texture gets drawn on screen. Did not seem to help. ### ~~Actors do not scale~~ > Fixed in 0a8bce708e6f3d81c3ad222abf40624b6c538b67 When zoomed in or out, actors remain visually on-screen in exactly the same spot they were, they do not change with the level. It should need: * Passing the parent Canvas.Zoom level on to child Canvas's so they upscale their drawing the same amount. * And also fixing the X,Y position of the actor so they move relative to the level on zoom. * And also resizing the W,H of the actor Canvas widget to fit the zoomed size (easy part). Lowest priority of all the issues. ### ~~Link lines do not draw correctly~~ > Fixed in fd730483b0cfeb8051584a25873184639c509c33 As the doodads in the level move position and size during zoom, the pink lines connecting linked doodads together don't move at all. They still point to positions on screen where doodads would have been without zooming. ### ~~Actor Hitboxes for Actor/Link Tool~~ > Fixed in fd730483b0cfeb8051584a25873184639c509c33 When the Actor Tool or Link Tool is selected, actors in your level should outline in orange or pink on mouse hover. This was not scaling up correctly when zoomed in. If scrolled to 0,0 (default) all was fine when zoomed, but as the level scrolled the hitboxes would drift apart.
kirsle added the
enhancement
label 2021-07-13 05:42:40 +00:00
kirsle added this to the Itch.io Launch milestone 2021-10-05 05:05:55 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SketchyMaze/doodle#37
There is no content yet.