Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the module turtle, color() doesn't change the color of write() #2223

Open
mobluse opened this issue Aug 26, 2024 · 7 comments
Open

In the module turtle, color() doesn't change the color of write() #2223

mobluse opened this issue Aug 26, 2024 · 7 comments
Assignees

Comments

@mobluse
Copy link

mobluse commented Aug 26, 2024

Describe the bug

In the module turtle, color() doesn't change the color of write(). E.g.

from turtle import *
color("blue")
write("Hello, world.")

types text in black.

Screenshots

The same program running on Numworks and in Python3 in Linux:
download-planet
2024-08-26-120405_422x334_scrot

To Reproduce

Steps to reproduce the behavior:

  1. Try the script on https://my.numworks.com/python/mobluse/planet
  2. See that in Numworks the text is black; not blue.

Expected behavior

The text written using write() should have the same color as lines drawn using the turtle.

Environment

  • Epsilon version: 23.2.1.
  • The platform(s) on which the problem happens: online simulator, actual device
@mobluse mobluse changed the title In the module turtle, color() doesn't change the color of write In the module turtle, color() doesn't change the color of write() Aug 26, 2024
@numworks numworks deleted a comment Aug 26, 2024
@Idaill
Copy link

Idaill commented Aug 31, 2024

Im gonna answer you : color("blue") doesn't choose the color blue, it just return a value, here if you do print(color("blue")) it will return (0,0,255) . If you want to change the color, well just use kandinsky library, it's easier and faster, if you want to write a text using this, do draw_string("text",x,y,color_background_of_text,color_text) . Have a nice day !

@Idaill
Copy link

Idaill commented Aug 31, 2024

color("blue") does not affect write but affect the color of lines, i think this is not a bug and this is just that they dont think of adding this possibility .

@EmilieNumworks
Copy link
Collaborator

It's indeed a feature and not a bug but we can consider adding the feature though @adri1numworks.

@mobluse
Copy link
Author

mobluse commented Sep 14, 2024

Im gonna answer you : color("blue") doesn't choose the color blue, it just return a value, here if you do print(color("blue")) it will return (0,0,255) . If you want to change the color, well just use kandinsky library, it's easier and faster, if you want to write a text using this, do draw_string("text",x,y,color_background_of_text,color_text) . Have a nice day !

I believe you mix up color() in turtle with color() in kandinsky. color() in kandinsky is a constructor and works as you write, but color() in turtle is a method that changes the color of what the (default) turtle draws, and that should include text, since that is how turtle in CPython (standard Python for computers) works. If turtle in NumWorks doesn't work as turtle in CPython, it is more difficult to port programs from NumWorks to CPython.
download (2)

@mobluse
Copy link
Author

mobluse commented Sep 15, 2024

I've noticed that NumWorks' turtle also has pencolor() (undocumented in NumWorks' manual) that also doesn't change the write() color, but in CPython pencolor() like color() changes the write() color. color() in CPython changes both pencolor and fillcolor, but NumWorks doesn't have begin_fill() and end_fill().

@adri1numworks
Copy link

Thanks for your comments. An issue was created internally to make NumWorks Python correspond to CPython regarding turtle.color()

@mobluse
Copy link
Author

mobluse commented Oct 9, 2024

There is another issue with turtle.color(): When you run it without arguments in CPython it returns two colors; one for pencolor and one for fillcolor, but in NumWorks it only returns one color. I think turtle.color() should return two colors in a tuple just to be compatible with CPython even though fillcolor is not supported, since filling is not supported. You could have a fake fillcolor that is always the same as the pencolor.
screenshot (1)

Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle as t
>>> t.color()
('black', 'black')
>>> t.pencolor()
'black'
>>> t.fillcolor()
'black'
>>> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants