Turtle - rotate head when shape is set to image
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với các điểm vào của mô-đun turtle được nêu trong đề xuất, đặc biệt là Screen.addshape(), Turtle.shape() và các thay đổi về hướng, sau đó xem lại giải pháp mẫu được liên kết và PR gh-130855. Hoàn tất có nghĩa là các hình ảnh có thể tùy chọn xoay, đồng thời vẫn giữ nguyên hành vi hiện có khi tùy chọn bị bỏ qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- desktop
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100