日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
有趣的Python教程:Pygame翻轉(zhuǎn)圖像

要翻轉(zhuǎn)圖像,我們需要使用 pygame.transform.flip(Surface, xbool, ybool) 方法,該方法被調(diào)用來根據(jù)我們的需要在垂直方向或水平方向翻轉(zhuǎn)圖像。

語(yǔ)法:

pygame.transform.flip(Surface, xbool, ybool)

原始圖像如下:

垂直翻轉(zhuǎn)圖像

我們?cè)诖怪狈较蛏戏D(zhuǎn)圖像。我們將使用 pygame.transform.flip() 來垂直顯示圖像。將 xbool 作為 True 和 ybool 作為 False 傳遞,這樣圖像就會(huì)垂直翻轉(zhuǎn)。

代碼如下:

# 導(dǎo)入 pygame 和 sys
import pygame
import sys


from pygame.locals import *


# 初始化pygame
# 導(dǎo)入模塊
pygame.init()
pygame.display.set_caption('www.linuxmi.com')


# 圖像大小將顯示在屏幕上
screen = pygame.display.set_mode((1300, 600), 0, 32)


# pygame.image.load() 將返回
# 有圖像的對(duì)象
img = pygame.image.load('linuxmi.com.png')


while True:


# 背景顏色
screen.fill((255, 255, 255))


# 復(fù)制圖像
img_copy = img.copy()


# pygame.transform.flip() 將翻轉(zhuǎn)圖像
img_with_flip = pygnsformame.tra.flip(img_copy, False, True)


# surface.blit() 函數(shù)繪制一個(gè)源
# 在這個(gè)表面上
screen.blit(img_with_flip, (50 + 1 * 120, 100))


# 退出屏幕的事件偵聽器
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()


# 每秒更新幀數(shù)
pygame.display.update()

效果圖如下:

水平方向翻轉(zhuǎn)圖像

我們?cè)谒椒较蚍D(zhuǎn)圖像。對(duì)于這個(gè) xbool 作為 False 和 ybool 作為 True 傳遞,水平翻轉(zhuǎn)它。代碼如下:

# 導(dǎo)入 pygame 和 sys
import pygame
import sys


from pygame.locals import *


# 初始化pygame
# 導(dǎo)入模塊
pygame.init()
pygame.display.set_caption('www.linuxmi.com')


# 圖像大小將顯示在屏幕上
screen = pygame.display.set_mode((1300, 600), 0, 32)


# pygame.image.load() 將返回
# 有圖像的對(duì)象
img = pygame.image.load('linuxmi.com.png')


while True:


# 背景顏色
screen.fill((255, 255, 255))


# 復(fù)制圖像
img_copy = img.copy()


# pygame.transform.flip() 將翻轉(zhuǎn)圖像
img_with_flip = pygame.transform.flip(img_copy, False, True)


# surface.blit() 函數(shù)繪制一個(gè)源
# 在這個(gè)表面上
screen.blit(img_with_flip, (50 + 1 * 120, 100))


# 退出屏幕的事件偵聽器
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()


# 每秒更新幀數(shù)
pygame.display.update()

顯示如下:

OK,你學(xué)會(huì)了嗎?


新聞名稱:有趣的Python教程:Pygame翻轉(zhuǎn)圖像
本文鏈接:http://www.5511xx.com/article/cojjsch.html