Math to get relative scale from level stack

后端 未结 3 1710
清酒与你
清酒与你 2021-01-28 11:18

Apologies for the horrible title. I spent 10 minutes trying to explain this in one sentence and failed.

Although the application prompting this question is in Java (And

3条回答
  •  無奈伤痛
    2021-01-28 11:44

    so far...

    public static void getZoom(int currentLevel, double userScale){
            double ns = (1 << (currentLevel - 1)) * userScale;
            int newLevel = 1;
            int ts = 1;
            while(ts < ns){
                ts <<= 1;
                newLevel++;
            }
            double newScale = ns / ts;
            System.out.println(newLevel + ", " + newScale);
        }
    

提交回复
热议问题