pygame拖动图片与缩放示例_python图像查看器雏形程序

"""
   拖动图片与缩放示例
   稍微改下这个程序就能制作一个图片查看器了.
   
"""

import pygame
from pygame.locals import *

width,height = 680,660
pos = [width//2,height//2]
image = 'beauty.jpg'

screen = pygame.display.set_mode((width,height))
pygame.display.set_caption("拖动图片与缩放示例www.lixingqiu.com")
image = pygame.image.load(image).convert_alpha()
rect = image.get_rect(center=pos)
image2 = image

w,h = image.get_width(),image.get_height()
k = h/w                                   # 高度和宽度之比
step = 10
start_drag = 0
running = True
while running:
    for event in pygame.event.get():
              
        if event.type == QUIT:running = False
        
        if event.type == MOUSEBUTTONDOWN:

You must log in to read the rest of this article. Please log in or register as a user.