pygame transform scale

Solutions on MaxInterview for pygame transform scale by the best coders in the world

showing results for - "pygame transform scale"
Philipp
20 Oct 2016
1import pygame
2picture = pygame.image.load(filename)
3picture = pygame.transform.scale(picture, (1280, 720))
4
Salma
22 May 2020
1pygame.transform.scale(Surface, (width, height), DestSurface = None)
Kyle
06 Jan 2017
1import pygame
2import pygame.font
3
4pygame.init()
5size = (400,400)
6screen = pygame.display.set_mode(size)
7clock = pygame.time.Clock()
8
9def blitRotate(surf, image, pos, originPos, angle):
10
11    # calcaulate the axis aligned bounding box of the rotated image
12    w, h       = image.get_size()
13    box        = [pygame.math.Vector2(p) for p in [(0, 0), (w, 0), (w, -h), (0, -h)]]
14    box_rotate = [p.rotate(angle) for p in box]
15    min_box    = (min(box_rotate, key=lambda p: p[0])[0], min(box_rotate, key=lambda p: p[1])[1])
16    max_box    = (max(box_rotate, key=lambda p: p[0])[0], max(box_rotate, key=lambda p: p[1])[1])
17
18    # calculate the translation of the pivot 
19    pivot        = pygame.math.Vector2(originPos[0], -originPos[1])
20    pivot_rotate = pivot.rotate(angle)
21    pivot_move   = pivot_rotate - pivot
22
23    # calculate the upper left origin of the rotated image
24    origin = (pos[0] - originPos[0] + min_box[0] - pivot_move[0], pos[1] - originPos[1] - max_box[1] + pivot_move[1])
25
26    # get a rotated image
27    rotated_image = pygame.transform.rotate(image, angle)
28
29    # rotate and blit the image
30    surf.blit(rotated_image, origin)
31
32    # draw rectangle around the image
33    pygame.draw.rect (surf, (255, 0, 0), (*origin, *rotated_image.get_size()),2)
34
35font = pygame.font.SysFont('Times New Roman', 50)
36text = font.render('image', False, (255, 255, 0))
37image = pygame.Surface((text.get_width()+1, text.get_height()+1))
38pygame.draw.rect(image, (0, 0, 255), (1, 1, *text.get_size()))
39image.blit(text, (1, 1))
40w, h = image.get_size()
41
42angle = 0
43done = False
44while not done:
45    clock.tick(60)
46    for event in pygame.event.get():
47        if event.type == pygame.QUIT:
48            done = True
49        elif event.type == pygame.KEYDOWN:
50            if event.key==pygame.K_ESCAPE:
51                done = True
52
53    pos = (screen.get_width()//2, screen.get_height()//2)
54    pos = (200, 200)
55
56    screen.fill(0)
57    blitRotate(screen, image, pos, (w//2, h//2), angle)
58    angle += 1
59
60    pygame.draw.line(screen, (0, 255, 0), (pos[0]-20, pos[1]), (pos[0]+20, pos[1]), 3)
61    pygame.draw.line(screen, (0, 255, 0), (pos[0], pos[1]-20), (pos[0], pos[1]+20), 3)
62    pygame.draw.circle(screen, (0, 255, 0), pos, 7, 0)
63
64    pygame.display.flip()
65
66pygame.quit()
67
Sofia
23 May 2018
1#Start Libraries
2import pygame, sys
3from pygame.locals import *
4#End Libraries
5
6pygame.init() #We're initializing the script
7
8pygame.display.set_caption('Platform') #This is the name of the window
9window_size = (600,400) #The size of the window
10screen = pygame.display.set_mode(window_size) #Initializing the screen
11
12image_not_scaled = pygame.image.load('file_path.png').convert() #Importing the image
13image = pygame.transform.scale(image_not_scaled, (32, 32)) #You can insert whatever you want for example (64, 64)
14														   #It MUST be a tuple
15
16#Now we'll create the while loop
17run = True #With this we can control the script (stop it)
18while run: #For NOW itz a simple while true
19    screen.fill((255, 255, 255)) #Filling the screen with white
20    screen.blit(image, (0, 0)) #Blitting the image on the screen
21
22    for event in pygame.event.get(): #Checking the events
23        if event.type == QUIT: #Checking if the event is QUIT
24            pygame.quit() #In that case we'll exit from pygame
25            sys.exit() #In that case we'll exit from the script
26    
27    pygame.display.update() #Updating the screen
28
Sergio
08 Nov 2017
1import pygame
2
3# Load picture
4picture = pygame.image.load("your/file/directery.png") # choose a picture and spesefy directery
5
6# Resize
7picture = pygame.transform.scale(picture # spesefy the objekt, (100, 100))# here is the scale by pixels
queries leading to this page
pygame scaling imagepygame transformenlarge a texture pygamehow to rotate an image in pygamepygame convert size of imagehow to rotate a image in pygamewresize a picture pygamehow to resize an image in pygamehow to resize in pygamepygame scale surfaceset rotation of image pygamehow to rotate a image in pygamescreen blit sizehow to rotate image in pygamepygame how to change image sizehow to scale image pygamehow to modify screen size to picture pygamepygame scale all imagespygame make smallerhow to resize a image pygamehow to make an image rotate in pygamehow to decrease the image size in pygamehow to resize an image to smaller in pygamewhy isn pygame transform scale workingpygame image scaling too largecan you change the size of an image in pygamehow to transform scale in pygamehow to change size of a picture pygamescale image to be smaller in pygameresize and imagepygamescale image to window pygamepygame change angle imageshow to resize an image pygamechange image sixe pygamehow to shrink image pygamepygame rotating imagehow to rotate images in pygamepygame image scalescale pygameimage pygame transform positionpygame transform image sizezpygame alter image sizepygame how to resize imagehow to scale an image in pygamehow to decrease size of an image in pygamepygame transform rotaterotate images in pygamescale image pygamerotate recntanlge image pygamepygame transform scale 28pygame image load 28 29 29risizable image in pygamehow to change size of image in pygamehow to resize an image in pygame without losing qualitypygame transform scalehow to shrink an image pygamepygame scale actually cutting off imagetransform scale pygamepygame transform scalechange size of image in pygamehow to scale and rotate image in pygamepygame resize imaghepygame transform scaletranformation image in pygamepygame how to resize an imagepygame image wont scalehow to increase the size of the image in pygamepygame rotate image around centerpygame how do i scale an image by 1 5resize pygame load imagecan we change the resolution of an image in pygame 3fhow to rotate image through mouse in pygamehow to resize image in pygamepygame scaling not working on full imageset rotation of image in pygamepygame how to resize an imresize images in pygamescale an image down pygameset dimensions of image pygamehow to rotate images in pygame on an axisbetter pygame transform scaleresize image in pygamepygame blit scalescaling images pygameimage size pygamepygame image rotationpygame image rotate centerpygame transform recalehow to change the size of picture in pygame 5cpygame make image biggerhow to make pygame tranform scale betterpygame rotate memorypygame get size of scaled imagetransform scale documentation pygamehow to shrink a picture pygamerotate a surface pygmaehow to resize imgs in pygamepygame transform flippygame resize image resolutionpygame transform rotateresize image pygamepygame resize imagerotate img pygamepygame rotate a drawn rectpygame change resolution of imagemake image smaller pygamepygame increase image sizerotate in pygamescaling a pygame imagepython pygame how to change the size of an imagepygame get image scalepygame surface get rotationhow to change a images size in pygamepygame rotate image around pointpygame crop imagehow to scale an image by 2 in pygamehow to make an image smaller in pygamehow to size an image pygamehow to change scale of an image in pygamehiw ti resize image in pytgamepygame blit image smallerpython pygame rotate functionpygame image shrink to sizepygame resize picturepygame transform rotate objectpygame rotate image 5cscale pygame imagemake image bigger pygamepygame transform rotate 28 29pygame transform rotozoompython pygame display image biggerpygame image resizehow to resize images in pygamepygame rotate image around pivotpygame load images and scale itpygame transform scale 28 29how to reduce the dimensions of an image in pygameresize pygame imagehow to rotate from centre of image pygamehow to rotate a picture in pygamepygame image rotatehow to resize and display an image in pygamepygame background image full screenchange the resolution of a picture in pygamepygame transform scale 2xpygame image transform scalepygame changing size of imagescale images to window size pygametransform image pygameset scale pygamescale tranformation image in pygamepygame draw blit image smallerhow to stretch a surface in pygamehow to rotate an image using rect and vector in pygamehow ro resize an imag3e in pygamehow to change the scale of a picture in pygamepygame resize iamgepygame function that rotate an imagerotate an image pygameshould resized images be converted pygamehow to make a cimage grow then shrink in pygamerotate pygametransform rotate pygamehow to changet the size of picture in pygame 5chow to change the size of imges in pygamepygame rotate transformchange size image pygamescaling image in pygamescale an image pygamepygame shrink imagepygame draw image with set sizehow to rotate image pygametransform an image on a surfacescale image in pygamehow to scale images pygamepygame transform flip vs rotatepygame changingsize of imagepygame scale image downhow to change the size of a image python pygameresize surface pygameimage size adjust on pygamepygame scale imagespytgame transform rotate 28 29setting the size of an image in pygamehow to load images with pygame with scalehow to rotate a sprite pygamepygame change the size of imagephoto size in pygame 5d 5cpygame blit rotationchange size of image pygamepygame trasnform scalehow to resize image pygamehow to change a size of an image in pygamepygame scale image 2xpygame sizepygame zoomtransform pygamerotate image pygaemhow to rotate img in pygame horizontalyhow to resize pygame imagepygame transformsmooth transformation pygamepygame transform scale 28pygame image loadrotate photo in pygamehow to resize imag ein pygameshrink image pygamescale pygame surfacerotate image in pygamehow to resize an image in python using pygamehow to change the size of images pygamehow to scale in pygamehow can we rotate a image about a point in pygamepygame how to change scalehow to rotate a image to mouse in pygamepygame change image based on pixel sizehow do i shrink a image in pygame in pythonpygame change size of imagemaking an image smaller pygameresizing images in pygamerotate image pygamehow to change image size in pygamepygame size of a scaled imagepygame image transform rotate 28 29image scale pygamepygame transform rotatepygame rotate spriteresize img pygamehow make an image smaller in pygamepygame scale percentagepygame image dimensionsrotate image crashing pygamehow to set image size in pygamepygame size imageptgame rotate imagepygame rescale imagescale down image pygamescaling images in pgamechange image size pygamehow to change size of image pygamepygame load and scaletransform image on load pygamepygame scale an image downhow to reduce the scale of an image python pygamepygame scale image to halfrotater img pygameresize loaded image pygamehow to change the size of an image in pygamehow to rotate image to a angle in pygameresizing images pygamehow do i shrink a image in pygamepygame change width of imagepygame transform fliphow to make image smaller pygamehow to downscale an image pygamepygame rotate image to mouserotating image pygameresize an image in pygamerotate image from center pygamehow to scale image in pygamepygame rotate objectpygame set image sizepygame image rotatehow to scale and transform image pygamerotate image around center pygameresize an image pygamehow to rotate an image around it center in pygamescale an image up pygamepygame scale down imagepygame resize an imagepygame stretch imagepygame change image sizerescale image pygamerotate image python pygamehow to scale images in pygamepygame image stretchpygame scalehow to upscale an image pygamechange size image python pygamehow can i render jpeg images in pygamepygame get image sizerotation image pygamepygame image transformhow to scale screen size to image in pygamehow to define size of image in pygamehow to downscale an image in pygamepygame how to resize an image to fullscreenpygame flip imagepygame set image rotationset image size pygamepygame rotatingcan you downsize a photo in pygamescaling pygame imagepygame change surface sizechange the image size in pygamehow to shrink image size pygameblit rotate pygamepygame rotationpygame change angle of imagerescalse image pygamepygame display and scale imagehow to change capacity of image in pygamehow to alter image size pygame blithow to change the size of image in pygamerezise object pygamechange image size in pygamepygame rotate surfacepygame scale image sizepygame how to resize a pic to screen sizepygame how to scale imagehow to rotate an image pygamehow to scale an image pygamehow to set the scale of an image in pygamehow to change the size od an image in pygame pythonhow to change the dimesions of an image pygamepygame scale image to fit rectanglepygame scale up imagehow to scale a image in pygamehow to shrink a image in pygamerotate rect pygamepygame image sizepygame how to increase image sizescale img pygamepygame image set sizehow to rotate a image about a point in pygamehow to resize image with pygamehow to shrink an image in pygamepygame set rotation of imagepygame scale imagepygame load image at scaletransform size of picture pygamehow to scale down pygame imagepygame transform scale examplepygame rotate imagespygame scale an imageupscale images pygamepygame rotate image scale surface pygameblit an image pygame at double sizedraw image bigger pygamehow to rotate img in pygamepygame rotateresizing image pygamehow to change the scale in pygame of an imgagepygasme scalescale transformation image in pygametransform scale in pygamepygame transform laplacian 28 29pygame transform scale