def scaled_resize_window(self, width, height):
        """One of two possible methods that are called when the main window is resized.

        This implementation scales the display such that the initial resolution
        requested by the programmer (the "logical" resolution) is always retained
        and the content scaled to fit the physical display.

        This implementation also sets up a 3D projection for compatibility with the
        largest set of Cocos transforms.

        The other implementation is `unscaled_resize_window`.

        :Parameters:
            `width` : Integer
                New width
            `height` : Integer
                New height
        """
        # physical view size
        pw, ph = width, height
        # virtual (desired) view size
        vw, vh = self.get_window_size()
        # desired aspect ratio
        v_ar = vw / float(vh)
        # usable width, heigh
        uw = int(min(pw, ph * v_ar))
        uh = int(min(ph, pw / v_ar))
        ox = (pw-uw) // 2
        oy = (ph-uh) // 2
        self._offset_x = ox
        self._offset_y = oy
        self._usable_width = uw
        self._usable_height = uh
        self.set_projection()

        if self._resize_no_events:
            # setting viewport geometry, not handling an event
            return

        # deprecated - see issue 154
        self.dispatch_event("on_resize", width, height)

        self.dispatch_event("on_cocos_resize", self._usable_width, self._usable_height)

        # dismiss the pyglet BaseWindow default 'on_resize' handler
        return pyglet.event.EVENT_HANDLED
dataset/ETHPy150Open los-cocos/cocos/cocos/director.py/Director.scaled_resize_window/original