Skip to content

Turtle - rotate head when shape is set to image #130715

@kbialowas

Description

@kbialowas

Feature or enhancement

Proposal:

I found turtle module to be a great way to introduce my kid to programming. I spotted that he is especially enjoying some interactive scripts, that react to keys or clicking. My problem is that currently when head shape is set to an image, it's not getting rotated which is quite a limitation when it comes to achieving some interesting effects while keeping the code simple.

Would you consider adding an option to rotate turtle head shape when it's set to an image to the library?

Sample code could work like this:

import turtle

sc = turtle.Screen()
sc.addshape("./car.png", rotate_image_shape=True)

t = turtle.Turtle()
t.shape("./car.png")

def handle_click(x,y):
    t.setheading(t.towards(x,y))
    t.goto(x,y)

sc.onclick(handle_click)

turtle.mainloop()

so unless you explicitly say that you want to rotate image shape, it would work as it used to.

I did some research and implemented sample solution here:
main...kbialowas:cpython:tilt-turtle-transformation

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

https://discuss.python.org/t/turtle-make-it-possible-to-tilt-image-shape/81890/2

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions