pixi-viewport icon indicating copy to clipboard operation
pixi-viewport copied to clipboard

Any way to get current zoom value?

Open nazywamsiepawel opened this issue 4 years ago • 1 comments

Hey,

I set up pixi viewport like this:

    this.viewport
      .pinch()
      .wheel({ smooth: 3 })
      .clampZoom({
        minWidth: 300,
        minHeight: 300,
        maxWidth: 8000,
        maxHeight: 8000,
      })
      .decelerate();

So users can pinch to zoom while in the game. Is there any possibility to get the percentage value of the current zoom in the library? I'm trying to calculate it but I'm wondering if there is possibly any ready value / function that I could refer to.

nazywamsiepawel avatar May 10 '21 11:05 nazywamsiepawel

The current zoom is viewport.scale.x. If your default zoom is 1, then that's the percent (multiplied by 100). If default zoom is not one, then divide by the default zoom before multiplying by 100.

davidfig avatar May 10 '21 21:05 davidfig