def mask_by_replacing(self, surf):
        """Mask out pixels by replacing alpha values.

        Best suited to use in surfaces which, despite having
        an alpha channel, all of its alpha values are 255.
        That is, all of its pixels have solid colors.

        Parameters
        ==========
        surf (pygame.Surface instance)
            surface to be masked out by having its alpha
            values replaced by the alpha from the mask.
        """
        ### create an array which directly references the
        ### surface's alpha values;
        ###
        ### that is, changes in the values of this array
        ### are reflected in the alpha of the pixels in
        ### the surface;
        ###
        ### the surface remains locked for the lifetime of
        ### this array (which is why we'll soon delete it
        ### once we don't need it anymore)
        surf_alpha_values = pixels_alpha(surf)

        ### iterate over the columns of full alpha values
        ### from both the surface and this alpha mask,
        ### using slice assignment to replace the values
        ### from each surf's column by the values from
        ### each mask's column

        for surf_alpha_column, mask_full_alpha_column in zip(
            surf_alpha_values, self.full_alpha_values
        ):

            surf_alpha_column[:] = mask_full_alpha_column

        ### delete references to the array so the surface is
        ### unlocked;
        ###
        ### the array would be automatically garbage
        ### collected anyway once the method returned,
        ### but we prefer to be explicit about this,
        ### especially given the importance of this operation
        del surf_alpha_column, surf_alpha_values
Mask out pixels by replacing alpha values.

        Best suited to use in surfaces which, despite having
        an alpha channel, all of its alpha values are 255.
        That is, all of its pixels have solid colors.

        Parameters
        ==========
        surf (pygame.Surface instance)
            surface to be masked out by having its alpha
            values replaced by the alpha from the mask.
        
nodezator/alphamask/basicop.py