I had been trying to rotate an image around its center in using pygame.transform.rotate()
but it’s not working. Specifically the part that hangs is rot_image = rot_image.subsurface(rot_rect).copy()
. I get the exception:
ValueError: subsurface rectangle outside surface area
Here is the code used to rotate an image:
def rot_center(image, angle): """rotate an image while keeping its center and size""" orig_rect = image.get_rect() rot_image = pygame.transform.rotate(image, angle) rot_rect = orig_rect.copy() rot_rect.center = rot_image.get_rect().center rot_image = rot_image.subsurface(rot_rect).copy() return rot_image
Related Posts:
- Process finished with exit code -1073741515 (0xC0000135)
- ImportError: No module named ‘pygame’
- ImportError: No module named ‘pygame’
- pygame.error: video system not initialized
- pygame.error: video system not initialized
- How to draw a circle in PyGame?
- pygame.error: video system not initialized
- TypeError: object of type ‘int’ has no len() – Python/Pygame
- Pygame Drawing a Rectangle
- How do I detect collision in pygame?
- How to display text in pygame?
- How to get keyboard input in pygame?
- Countdown timer in Pygame
- pygame clock.tick() vs framerate in game main loop
- Start with pyglet or pygame?
- Pygame mouse clicking detection
- Python Array Rotation
- How can I create a text input box with Pygame?
- How do I maximize the display screen in PyGame?
- How to install PyGame on Python 3.4?
- How to use pygame.KEYDOWN to execute something every time through a loop while the key is held down?
- How to clear up screen in pygame?
- Installation of pygame with Anaconda
- How to add a background image into pygame?
- TypeError: ‘int’ object is not callable
- Is a Python dictionary an example of a hash table?
- Why does this iterative list-growing code give IndexError: list assignment index out of range?
- Modifing data while using iterrows() does not work
- difference between command prompt and anaconda prompt
- Do I understand os.walk right?
- Pandas “Can only compare identically-labeled DataFrame objects” error
- ImportError: DLL load failed: %1 is not a valid Win32 application. But the DLL’s are there
- SyntaxError: multiple statements found while compiling a single statement
- How can I remove a trailing newline?
- Pycharm exit code 0
- How do you split a string in Python with multiple delimiters?
- syntaxError: ‘continue’ not properly in loop
- ValueError: all the input arrays must have same number of dimensions
- How do I do a case-insensitive string comparison?
- How to fix ‘ValueError: list.remove(x): x not in list’ error in Python
- How can I convert radians to degrees with Python?
- How to initialize a two-dimensional array in Python?
- IndexError: index 1 is out of bounds for axis 0 with size 1/ForwardEuler
- selenium – chromedriver executable needs to be in PATH
- TypeError: tuple indices must be integers, not str
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- Full examples of using pySerial package
- Checking whether a variable is an integer or not
- Using headers with the Python requests library’s get method
- How to measure elapsed time in Python?
- Issues using Keras np_utils.to_categorical
- Flask ImportError: No Module Named Flask
- Running an outside program (executable) in Python?
- TypeError: ‘dict_keys’ object does not support indexing
- Add Variables to Tuple
- What does socket binding mean?
- How to strip all whitespace from string
- Python Binomial Coefficient
- Pandas – How to flatten a hierarchical index in columns
- What is the difference between json.load() and json.loads() functions
- Viewing all defined variables
- python error: TypeError: an integer is required
- Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
- Get an attribute value based on the name attribute with BeautifulSoup
- getting ValueError : “Can only tuple-index with a MultiIndex “
- ModuleNotFoundError: No module named ‘seaborn’ in Python IDE
- UnicodeEncodeError: ‘charmap’ codec can’t encode characters
- Is there a ceiling equivalent of // operator in Python?
- Groupby value counts on the dataframe pandas
- How to plot an array in python?
- If statement for strings in python?
- How to create a numpy array of all True or all False?
- mean, nanmean and warning: Mean of empty slice
- SystemError: new style getargs format but argument is not a tuple?
- Python Set Comprehension
- Split string using a newline delimiter with Python
- Why am I getting ImportError: No module named pip ‘ right after installing pip?
- No module named urllib3
- How to convert index of a pandas dataframe into a column
- Python requests SSL error – certificate verify failed
- How to know/change current directory in Python shell?
- Trying to run Flask app gives “Address already in use”
- creating sets of tuples in python
- Using the AND and NOT Operator in Python [duplicate]
- How can I make one python file run another? [duplicate]
- Error: No module named ‘fcntl’
- “Can’t convert ‘float’ object to str implicitly”
- Python can’t find file
- Plotting graphs in C++
- ‘MyClass’ object has no attribute ‘__getitem__’
- Can’t install Scipy through pip
- How to run python code in Sublime Text 3?
- Random word generator- Python
- How can I install the Beautiful Soup module on the Mac?
- How to change the Spyder editor background to dark?
- Python convert tuple to string
- Does Python have an immutable list?
- __init__() got an unexpected keyword argument ‘user’
- Create dynamic URLs in Flask with url_for()