Turtle - rotate head when shape is set to image
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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:
https://github.com/python/cpython/compare/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
- gh-130855
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit den im Vorschlag gezeigten Einstiegspunkten des turtle-Moduls, insbesondere Screen.addshape(), Turtle.shape() und Änderungen der Ausrichtung, und sehen Sie sich anschließend die verlinkte Beispielimplementierung und PR gh-130855 an. Erledigt ist die Aufgabe, wenn Bildformen die Rotation optional aktivieren können und das bisherige Verhalten erhalten bleibt, wenn die Option weggelassen wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- desktop
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100