Turtle - rotate head when shape is set to image
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dai punti di ingresso del modulo turtle mostrati nella proposta, in particolare Screen.addshape(), Turtle.shape() e le modifiche alla direzione, quindi esamina la soluzione di esempio collegata e il PR gh-130855. Il lavoro è completato quando le forme immagine possono scegliere di ruotare, mantenendo il comportamento esistente quando l’opzione viene omessa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- desktop
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100