Open mobluse opened 2 months ago
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 !
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 .
It's indeed a feature and not a bug but we can consider adding the feature though @adri1numworks.
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.
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()
.
Thanks for your comments. An issue was created internally to make NumWorks Python correspond to CPython regarding turtle.color()
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.
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'
>>>
Describe the bug
In the module turtle,
color()
doesn't change the color ofwrite()
. E.g.types text in black.
Screenshots
The same program running on Numworks and in Python3 in Linux:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The text written using write() should have the same color as lines drawn using the turtle.
Environment