read/write disks
This commit is contained in:
parent
c2ebf92a0e
commit
dd5917cd45
@ -450,6 +450,8 @@ class Painter(Widget):
|
||||
for particle in self.particles:
|
||||
if type(particle)==Cross:
|
||||
ff.write("{:d};".format(CROSS_INDEX))
|
||||
elif type(particle)==Disk:
|
||||
ff.write("{:d};".format(DISK_INDEX))
|
||||
ff.write("{:05.2f},{:05.2f};{:3.1f},{:3.1f},{:3.1f}\n".format(particle.elements[0].pos.x,particle.elements[0].pos.y,particle.color[0],particle.color[1],particle.color[2]))
|
||||
ff.close()
|
||||
|
||||
@ -527,6 +529,8 @@ class Painter(Widget):
|
||||
continue
|
||||
if particle_type==CROSS_INDEX:
|
||||
candidate=Cross(pos.x,pos.y,color=color)
|
||||
elif particle_type==DISK_INDEX
|
||||
candidate=Disk(pos.x,pos.y,color=color)
|
||||
else:
|
||||
print("warning: ignoring line "+str(i)+" in file '"+file+"': unrecognized particle type: '"+entries[0]+"'",file=sys.stderr)
|
||||
continue
|
||||
@ -579,5 +583,6 @@ class Painter(Widget):
|
||||
|
||||
# global variables (used like precompiler variables)
|
||||
CROSS_INDEX=1
|
||||
DISK_INDEX=2
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user