Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Turtle python graphics
#6
(Jun-10-2020, 09:30 AM)DPaul Wrote: Are you sure the coordinates draw a heart ? :-)
It works , but i get the start of a heart +/- ...
What i did:
D is now a list of dictionaries.
"For coord in D:" is what Yoriz says.
Each coord has 2 dictionary keys ['X'] and ['Y'], that give simple access to the values.
After that, piece of cake.
Also, do not include D in your def call, as D is visible from within the def.
Paul
yes it needs to draw an ugly heart ; maybe i didn't give it entirely ;
D1 = [{'X': -15, 'Y': 29}, {'X': -22, 'Y': 13}, {'X': -18, 'Y': -2}, {'X': -19, 'Y': -7}, {'X': -17, 'Y': -17}, {'X': -7, 'Y': -15}, {'X': -4, 'Y': -29}, {'X': 6, 'Y': -21}, {'X': 20, 'Y': -17}, {'X': 37, 'Y': -27}, {'X': 45, 'Y': -26}, {'X': 60, 'Y': 48}, {'X': 18, 'Y': 29}, {'X': 11, 'Y': 30}, {'X': -2, 'Y': 30}, {'X': -22, 'Y': 24}, {'X': -22, 'Y': 4}, {'X': -22, 'Y': 2}, {'X': -20, 'Y': -10}, {'X': -8, 'Y': -33}]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
it still doesn't work
def draw_figure(x0,y0):
    tracer(True)
    penup()
    goto(x0,y0)
    pendown()
 
begin_fill()
for coord in D:
        pen.right('X') #to access the index of X
        pen.left('Y')
end_fill()
 
print(draw_figure(10,20,D1))
Reply


Messages In This Thread
Turtle python graphics - by Y0sh1 - Jun-09-2020, 03:26 PM
RE: Turtle python graphics - by DPaul - Jun-09-2020, 03:44 PM
RE: Turtle python graphics - by Y0sh1 - Jun-10-2020, 08:59 AM
RE: Turtle python graphics - by Yoriz - Jun-09-2020, 03:50 PM
RE: Turtle python graphics - by DPaul - Jun-10-2020, 09:30 AM
RE: Turtle python graphics - by Y0sh1 - Jun-10-2020, 09:40 AM
RE: Turtle python graphics - by DPaul - Jun-10-2020, 10:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Graphics - Screen & Window Sizing jerryf 1 7,160 Feb-09-2023, 08:02 PM
Last Post: jerryf
  Python graphics kaltenherz 1 2,302 Sep-05-2021, 05:19 PM
Last Post: jefsummers
  Python 3 Turtle - Screen Events and Coords peteralien 0 2,535 Aug-18-2020, 11:25 PM
Last Post: peteralien
  For loops help, using python turtle SemiBeginnerPY 2 6,791 Mar-10-2020, 10:46 AM
Last Post: SemiBeginnerPY
  Python Turtle Help codinghero 1 23,938 Jan-04-2020, 12:46 AM
Last Post: ichabod801
  Python Graphics Help With Entries BadenJaden 1 72,693 Jul-24-2019, 10:36 PM
Last Post: Yoriz
  Python Turtle and order of implementation query Parsleigh 2 3,483 Mar-04-2019, 02:43 PM
Last Post: Parsleigh
  wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' Shadower 1 7,233 Feb-06-2019, 01:25 AM
Last Post: woooee
  Help! Turtle not working, even when we click the turtle demo in IDLE nothing happens. BertyBee 3 7,382 Jan-04-2019, 02:44 AM
Last Post: SheeppOSU
  from graphics import * jmaloney413 2 6,910 Oct-18-2018, 08:22 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020