Map Zoom

by Kaiochao
Let players zoom in and out of your map.
ID:1912458
 
Changes
  • 7 August 2015
    • Moved demo code to be included in every project, making this library plug-and-play. Just check the box next to this library in your Lib folder and it should work.
    • Added a zoom-level of 0, Stretch to Fit. It lives as the first, default zoom level.

Run the demo to see it in action. When you create a /map_zoom object, make sure to pass it the client you want it to affect.

You can specify the levels of zoom to go through. By default, it's 100%, 125%, 150%, 175%, 200%, 250%, 300%, then 400%. You call map_zoom.ZoomIn() to go up that series, and ZoomOut() to go down.

You can also specify the smoothing factor of the zoom to gradually, smoothly go between zoom levels. This is the map_zoom.zoom_smoothing variable. You can disable smoothing by setting to 1, or disable zooming by setting it to 0.

This library should automatically affect your default map control. If for some reason it's not working, you can set the map_zoom.map_id to your map control's ID as shown in the skin editor.

This library will never change your client and world.view variables.

Demo controls:

Keyboard!
  • Ctrl+Plus: Zoom In
  • Ctrl+Minus: Zoom Out
Mouse!
  • Ctrl+ScrollUp: Zoom In
  • Ctrl+ScrollDown: Zoom Out

*Note: Scroll detection is a feature of 508.1287 beta. It won't work in earlier versions.
Very cool! Is there a way for it to not disable Stretch icons to fit map option?
cool
In response to Zasif
I guess you could add 0 (stretch to fit) to the zoom steps. The transition might look interesting.

Have any of you tried plugging this into any of your existing projects? If so, let me know how difficult it is to use.
I am going to try this in pondera.
By the way, got this error when compiling with the demo:
demo\demo.dm:1:error: unable to open <kaiochao\shapes\shapes.dme>.
In response to AERProductions
Sorry, the demo requires my shapes library. I figured it would download it automatically, unless you downloaded the Zip. Since it's included by the demo, it won't be included in your games that include this library.

Anyway, shape is a good library for... any project. ;)
In response to Kaiochao
Kaiochao wrote:
Sorry, the demo requires my shapes library. I figured it would download it automatically, unless you downloaded the Zip. Anyway, it's a good library for... any project. ;)

Yeah I figured that was the issue. I will report back with the results.

EDIT: Good Stuff, works in pondera and consider it added to the project I will put you in the credits. :)
Is it possible to clean up the black-flashing while zooming in and out? The first time I tried it, it wasn't as bad but it seems to of gotten worse.

I am using the beta (508.1294).
In response to AERProductions
AERProductions wrote:
Is it possible to clean up the black-flashing while zooming in and out? The first time I tried it, it wasn't as bad but it seems to of gotten worse.

The black-flashing didn't always happen in previous BYOND versions, so I'm considering it a BYOND bug.

Bug Report