Closed lifubang closed 4 years ago
The svg_turtle.py is in https://github.com/donkirkby/live-py-plugin/blob/master/test/PySrc/tools/svg_turtle.py
Thank you very much.
@donkirkby Excuse me, could you PTAL? If you can help me, it will be a big help for us. Thank you.
Hi there! Thanks for pointing out the dot()
method, I've never used that.
Are you asking for guidance on how to add the feature, or are you asking me to add the feature for you? If you're asking for guidance, I suggest you add a dot()
method to the SvgTurtle
class, and it should probably look a lot like the _draw_line()
method, but call cv.circle()
instead of cv.line()
.
Thanks for your interest in the project. I'd love to hear how you found out about it, and what you've used it for.
I teach students to learn python turtle, so I need students to hand in their homework, they use svg_turtle
to save the result of their code.
I found out svg_turtle
from search engine, I found that svg_turtle
is used in wide range.
So I think we should support more features in svg_turtle
.
So, If you can add dot
in svg_turtle
, I may add other methods in it based on your example.
I added the dot()
method to SvgTurtle
, and I added a bgcolor
option to SvgTurtle.create()
. That makes it easier to create the turtle object and save the file. Here's an updated version of your example:
#!/usr/bin/env python
# coding=utf-8
from turtle import * # @UnusedWildImport
from svg_turtle import SvgTurtle
def write_file(draw_func, filename, size):
t = SvgTurtle.create(*size, bgcolor='white')
Turtle._screen = t.screen
Turtle._pen = t
draw_func()
t.save_as(filename)
def draw():
a = [[120.71, 50], [50, 120.71], [-50, 120.71], [-120.71, 50], [-50, -20.71], [50, -20.71], [20.71, 50],
[-20.71, 50]]
pencolor("red")
penup()
for pos in a:
goto(pos)
dot(10)
def main():
write_file(draw, 'test.svg', size=('500px', '500px'))
if __name__ == '__main__':
main()
Thank you very much. I will test it ASAP.
What I did
[feature request] Could you help to implement dot in svg_turtle?
What happened
When I run this code, got this error:
What I wanted to happen
Draw that dots in svg file
My environment
Describe the versions of everything you were using: