<> = pygame.transform = 对surface进行变换的pygame模块 Surface的变换是指移动或者缩放像素的操作。所有的这类函数都有一个Surface参数作为操作对象,并返回一个新的Surface作为操作的结果。 Some of the transforms are considered destructive. These means every time they are performed they lose pixel data. Common examples of this are resizing and rotating. For this reason, it is better to retransform the original surface than to keep transforming an image multiple times. (For example, suppose you are animating a bouncing spring which expands and contracts. If you applied the size changes incrementally to the previous images, you would lose detail. Instead, always begin with the original image and scale to the desired size.) == pygame.transform.flip == 垂直和水平翻转 {{{ pygame.transform.flip(Surface, xbool, ybool): return Surface }}} This can flip a Surface either vertically, horizontally, or both. Flipping a Surface is nondestructive and returns a new Surface with the same dimensions. == pygame.transform.scale == 缩放到新的大小 {{{ pygame.transform.scale(Surface, (width, height), DestSurface = None): return Surface }}} Resizes the Surface to a new resolution. This is a fast scale operation that does not sample the results. An optional destination surface can be used, rather than have it create a new one. This is quicker if you want to repeatedly scale something. However the destination must be the same size as the (width, height) passed in. Also the destination surface must be the same format. == pygame.transform.rotate == 旋转图像 {{{ pygame.transform.rotate(Surface, angle): return Surface }}} Unfiltered counterclockwise rotation. The angle argument represents degrees and can be any floating point value. Negative angle amounts will rotate clockwise. Unless rotating by 90 degree increments, the image will be padded larger to hold the new size. If the image has pixel alphas, the padded area will be transparent. Otherwise pygame will pick a color that matches the Surface colorkey or the topleft pixel value. == pygame.transform.rotozoom == 经过滤波的缩放和旋转 {{{ pygame.transform.rotozoom(Surface, angle, scale): return Surface }}} This is a combined scale and rotation transform. The resulting Surface will be a filtered 32-bit Surface. The scale argument is a floating point value that will be multiplied by the current resolution. The angle argument is a floating point value that represents the counterclockwise degrees to rotate. A negative rotation angle will rotate clockwise. == pygame.transform.scale2x == 特殊的图像2倍放大 {{{ pygame.transform.scale2x(Surface, DestSurface = None): Surface }}} This will return a new image that is double the size of the original. It uses the AdvanceMAME Scale2X algorithm which does a 'jaggie-less' scale of bitmap graphics. This really only has an effect on simple images with solid colors. On photographic and antialiased images it will look like a regular unfiltered scale. An optional destination surface can be used, rather than have it create a new one. This is quicker if you want to repeatedly scale something. However the destination must be twice the size of the source surface passed in. Also the destination surface must be the same format. == pygame.transform.chop == 图像剪切 {{{ pygame.transform.chop(Surface, rect): return Surface }}} Extracts a portion of an image. All vertical and horizontal pixels surrounding the given rectangle area are removed. The resulting image is shrunken by the size of pixels removed. (The original image is not altered by this operation.) = The end =