How to Scale and Rotate the texture region got from Image File.

39 views
Skip to first unread message

UMER FAROOQ

unread,
Dec 30, 2019, 6:32:41 PM12/30/19
to Kivy users support
### Versions

* Python: 3.7
* OS: Windows
* Kivy: 1.11.1
* Kivy installation method: Spyder Anaconda

### Description

I want to rotate the texture region obtained from the image file. I have a piece of code in Pygame which I want to convert into Kivy.

### Code and Logs
**A code in PyGame:**
```python
full_sprite =  pygame.image.load("./resources/images/full-sprite.png").convert_alpha()
rect = pygame.Rect(181, 1050,50,50)
cropped = full_sprite.subsurface(rect).copy()
pig_image = pygame.transform.scale(cropped, (30,30))
angle_degrees = math.degrees(pig.body.angle)
img = pygame.transform.rotate(pig_image, angle_degrees)
w,h = img.get_size()

```
This is how much I converted **into Kivy** but it is not working. I am not able to find any method to **scale and rotate the texture region**.
```python
full_sprite = Image(source='resources/images/full-sprite.png', allow_stretch=True)
full_sprite.texture = full_sprite.texture.get_region(181, 1050,50,50)
pig_image = full_sprite.texture
self.angle_degrees = math.degrees(pig.body.angle)
img = full_sprite.texture.Rotate(set(self.angle_degrees))

```
The provision of solution for this issue will be a great help to me.

Alexander Taylor

unread,
Jan 3, 2020, 4:39:08 PM1/3/20
to Kivy users support
Probably you don't want to scale and rotate the texture, but display the texture somehow (presumably a Rectangle) and scale/rotate that using the Scale and Rotate canvas instructions.
Reply all
Reply to author
Forward
0 new messages