def __init__(self, pos=0, factory=None): self.pos = pos if factory is None: self.factory = ParticleFactory(i=(pos * 100)) else: self.factory = factory
def __init__(self, pos=0, factory=None): self.pos = pos if factory is None: self.factory = ParticleFactory(i=(pos*100)) else: self.factory = factory
def make_scene(): """Returns the scene as an ElementTree.Element""" scene = ET.Element('scene') el = ET.SubElement(scene, 'description') el.set( 'text', 'Some ' + random.choice( ('weird', 'crazy')) + ' scene generated by make_scene.py') el = ET.SubElement(scene, 'duration') el.set('time', '60.0') el = ET.SubElement(scene, 'integrator') el.set('type', 'forward-backward-euler') el.set('dt', '0.01') #el = ET.SubElement(scene, 'maxsimfreq') #el.set('max', '500.0') el = ET.SubElement(scene, 'collision') #el.set('type', 'simple') #el.set('COR', '1') el.set('type', 'penalty') el.set('k', '10000') el.set('thickness', '0') el = ET.SubElement(scene, 'scenetag') el.set('tag', 'ParticleFountain') scene.append(ET.Element('simplegravity', {'fx': '0.0', 'fy': '-0.1'})) scene.append( ET.Element('backgroundcolor', { 'r': '0.7', 'g': '0.5', 'b': '1' })) # scene.append(make_particle()) # scene.append(make_particle(px='0.0', m='500', radius='0.1', vx='4')) # sine = make_sine() # for s in sine: # scene.append(s) pf = ParticleFactory() slide = Slide(pos=0, factory=pf) for s in slide.make(): scene.append(s) return scene
class Slide(): slide = [] i = 0 def __init__(self, pos=0, factory=None): self.pos = pos if factory is None: self.factory = ParticleFactory(i=(pos * 100)) else: self.factory = factory def make(self): """Returns the list of ElementTree elements for this slide.""" slide = [] xpos = 1 - 0.9 + random.random() ypos = (11 * self.pos) - 0.5 + random.random() slide.append( self.factory.make_particle( px=xpos, py=ypos, radius=(0.01), )) self.i += 1 slide.append(self.factory.make_particlecolor()) slide.append(self.factory.make_particlepath()) slide.append( self.factory.make_particle( px=xpos + 0.4, py=ypos + 0.2, radius=(1 * 0.2), )) for i in range(100): ii = i * random.random() slide.append(self.factory.make_particle(px=ii)) for i in range(50): slide.append(self.factory.make_edge(i - 1, i)) #slide.append(self.factory.make_edgecolor()) slide.append(self.factory.make_particlecolor()) return slide
class Slide(): slide = [] i = 0 def __init__(self, pos=0, factory=None): self.pos = pos if factory is None: self.factory = ParticleFactory(i=(pos*100)) else: self.factory = factory def make(self): """Returns the list of ElementTree elements for this slide.""" slide = [] xpos = 1 - 0.9 + random.random() ypos = (11 * self.pos) - 0.5 + random.random() slide.append(self.factory.make_particle( px=xpos, py=ypos, radius=(0.01), )) self.i += 1 slide.append(self.factory.make_particlecolor()) slide.append(self.factory.make_particlepath()) slide.append(self.factory.make_particle( px=xpos+0.4, py=ypos+0.2, radius=(1 * 0.2), )) for i in range(100): ii = i * random.random() slide.append(self.factory.make_particle(px=ii)) for i in range(50): slide.append(self.factory.make_edge(i-1, i)) #slide.append(self.factory.make_edgecolor()) slide.append(self.factory.make_particlecolor()) return slide