generated from mwc/project_drawing
first milestone/version drawing project
I was able to draw the rings using iteration and the 6 electrons to show a carbon atom. I found the turtle documentation to be helpful in finding some new functions to use such as moving to any spot in the coordinate plane and drawing the electrons as dots. For the next steps, I will try to incorporate some iteration for the drawing of the electrons since it is a repetitive process. I found both in this project and in the typeface problem set that I sometimes need to write the code out a few times before trying to add in the iteration. I then will animate the electrons and hope to be able to incorporate some type of input that enables my drawing to draw a Bohr model for different elements based on the user input, which is my longer term goal.
This commit is contained in:
parent
1cc4eddcb9
commit
4a58ce02b7
59
drawing.py
59
drawing.py
|
@ -5,3 +5,62 @@
|
|||
# (Briefly describe what this program does.)
|
||||
|
||||
from turtle import *
|
||||
from argparse import ArgumentParser
|
||||
import turtle
|
||||
|
||||
def draw_ring(ring):
|
||||
radius = ring*50
|
||||
circle(radius,360)
|
||||
penup()
|
||||
right(90)
|
||||
forward(50)
|
||||
left(90)
|
||||
pendown()
|
||||
|
||||
|
||||
def draw_electron():
|
||||
pencolor("red")
|
||||
turtle.dot(15)
|
||||
|
||||
def return_to_center():
|
||||
penup()
|
||||
turtle.goto(0,0)
|
||||
|
||||
'''def position_electrons(number):
|
||||
return_to_center()
|
||||
|
||||
|
||||
circle(radius*2,360)
|
||||
penup()
|
||||
right(90)
|
||||
forward(50)
|
||||
left(90)
|
||||
pendown()
|
||||
circle(radius*3)'''
|
||||
|
||||
|
||||
'''parser= ArgumentParser("python drawing.py")
|
||||
parser.add_argument("radius", type=int)
|
||||
args = parser.parse_args()'''
|
||||
|
||||
|
||||
for ring in range(4): #draws rings
|
||||
draw_ring(ring)
|
||||
return_to_center() #returns to center
|
||||
forward(50)
|
||||
draw_electron()
|
||||
back(100)
|
||||
draw_electron()
|
||||
return_to_center()
|
||||
forward(100)
|
||||
draw_electron()
|
||||
back(200)
|
||||
draw_electron()
|
||||
return_to_center()
|
||||
right(90)
|
||||
forward(100)
|
||||
draw_electron()
|
||||
back(200)
|
||||
draw_electron()
|
||||
input()
|
||||
|
||||
|
|
Loading…
Reference in New Issue