python / python/cpython

Turtle - rotate head when shape is set to image

Aberta
#130,715 3 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

stdlib type-feature
Linguagem predominante
Python
Estrelas
77.2k
Forks
35.9k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece pelos pontos de entrada do módulo turtle mostrados na proposta, especialmente Screen.addshape(), Turtle.shape() e as alterações de direção; em seguida, revise a solução de exemplo vinculada e o PR gh-130855. A tarefa estará concluída quando as formas de imagem puderem optar pela rotação, preservando o comportamento existente quando a opção for omitida.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
desktop
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.