python / python/cpython

Turtle - rotate head when shape is set to image

オープン
#130,715 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提案に示されている turtle モジュールのエントリポイント、特に Screen.addshape()、Turtle.shape()、heading の変更から始め、リンク先のサンプルソリューションと PR gh-130855 を確認してください。オプションを省略した場合は既存の動作を維持しつつ、画像形状で回転を選択できるようになれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
desktop
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。