(constraining, target_aspect)
Find most constraining dimension to scale.
Find most constraining dimension to scale.
Find most constraining dimension to scale .
def _most_constraining(constraining, target_aspect):
    """Find most constraining dimension to scale."""
    # we're assuming native pixels are square
    # so physical screen's aspect ratio is simply ratio of pixel numbers
    if constraining[0] / float(constraining[1]) >= target_aspect[0] / float(target_aspect[1]):
        # constraining screen has wider aspect than target screen
        # so Y is the constraining dimension
        # +------------+
        # |     +----+ |
        # |     |    | |
        # |     +----+ |
        # +------------+
        return 1
    else:
        # constraining screen has taller aspect than target screen
        # so X is the constraining dimension
        # +-----------+
        # | +-------+ |
        # | |       | |
        # | +-------+ |
        # |           |
        # +-----------+
        return 0
def _most_constraining ( constraining , target_aspect ) : # we're assuming native pixels are square # so physical screen's aspect ratio is simply ratio of pixel numbers if constraining [ 0 ] / float ( constraining [ 1 ] ) >= target_aspect [ 0 ] / float ( target_aspect [ 1 ] ) : # constraining screen has wider aspect than target screen # so Y is the constraining dimension # +------------+ # |     +----+ | # |     |    | | # |     +----+ | # +------------+ return 1 else : # constraining screen has taller aspect than target screen # so X is the constraining dimension # +-----------+ # | +-------+ | # | |       | | # | +-------+ | # |           | # +-----------+ return 0