This module is from turtledemo's planet_and_moon.py (but a more general version)
You can create the planet derectly because the GravSys is auto-created and can be created automatically.
Use Window() to get the Screen(a Screen() item of turtle module).
must add a mainloop() in the lastline of your code! or there will be an error from Threading!
but you can use GravSys.run() instead of GravSys.start() to avoid this, the disadvantage is that you must wait before
emulating end, and without mainloop(), the window will close after graphing.
atributes
m: mass
x: initial position(a Vec2D object, or Vec as an alia we provide)
v: initial position(a Vec2D object, or Vec as an alia we provide)
kwargs:
gravSys: a GravSys object, the gravity system that ths star exist;
If the attribute not exist, then:
1: if there have been a gravSys built, use the last one that created;
2: if there haven't been any gravSys, create one automatically.
shape: the shape of star;
we recommend you to use PLANET(equals to 'planet') as a planet that can be delight,
or STAR(equals to 'circle') as a sun that make light.
otherwise, it would be harder for user to watch(unless you have a specific use).
pc: pencolor, effective when pd is True.
pd: is pendown, a boolean.
default value: True
grav.setup([day_color[, night_color[, background]]])
a set-up function, which must be runned before create any planet, or there would be an error.
It can only be ran once.
background: a tuple: (mode, value)
mode has two available value: 'c' or 'f', if it isn't so, raise ValueError.
when mode is 'c', value is the color ("#XXXXXX",
or "black", "white", etc.,
or a (r, g, b) tuple) of background;
when mode is 'f', value is the path of background picture (only .gif file)
a Gravity System
gs = GravSys([dt[, t]])
(we suggest to use gs as the name of GravSys item)
dt is the smallest space between two postion changes.
t, which is writen as turn is module, is the total turns of simutation.
total time = turn * dt
(The following are copied from comments)
turn must be a int that greater than 0.
if it is 0, it can never stop!
start the time of gravity system.
the method ends as soon as simulation stops.
use run()
function in another thread.
return whether it had been setuped
try not to use this!
but is_setup()
instead!
Welcome to help test the module, any bugs, just edit it derectly and send the merge request.
Please write your change in the 'optional extended description'.
For example:
title: Update ...
descript: ver: x.x.x
what's new:......
Thank you for your download!