Пример #1
0
    def __init__(self, element, type, id=None):
        self._element = element

        if id is None:
            self._element.id = '%s_%s' % (type, int(100000 * random.random()))
        else:
            self._element.id = id
Пример #2
0
  def __init__(self, element, type, id=None):
      self._element=element

      if id is None:
         self._element.id='%s_%s' % (type, int(100000*random.random()))
      else:
         self._element.id=id
Пример #3
0
 def create_a_clip(a):
     Carta.CLIP += ["clip%d" % a]
     cs = ".clip%d {clip-path: url(#clipping%d);}\n" % (a, a)
     pt = "80,0 0,0" + "".join([" %d,%d" % (i, int(random()*40 +20)) for i in range(0,81,10)])
     #Carta.CLIP_POINTS.append[pt]
     clip = svg.clipPath(
         svg.polygon(points=pt), id="clipping%d" % a
         )
     defs <= clip
     return cs
Пример #4
0
 def create_a_clip(a):
     Carta.CLIP += ["clip%d" % a]
     cs = ".clip%d {clip-path: url(#clipping%d);}\n" % (a, a)
     pt = "80,0 0,0" + "".join([
         " %d,%d" % (i, int(random() * 40 + 20))
         for i in range(0, 81, 10)
     ])
     #Carta.CLIP_POINTS.append[pt]
     clip = svg.clipPath(svg.polygon(points=pt), id="clipping%d" % a)
     defs <= clip
     return cs
  def emitParticle(self):
      #Use an angle randomized over the spread so we have more of a "spray"
      angle = self._velocity.getAngle() + self._spread - (random.random() * self._spread * 2)
 
      #The magnitude of the emitter's velocity
      magnitude = self._velocity.getMagnitude()
 
      #The emitter's position
      _position = Vector(self._position._x, self._position._y)
 
      #New velocity based off of the calculated angle and magnitude
      _velocity = fromAngle(angle, magnitude)
     
      #return our new Particle!
      return Particle(position=_position, velocity=_velocity)
Пример #6
0
    def emitParticle(self):
        #Use an angle randomized over the spread so we have more of a "spray"
        angle = self._velocity.getAngle() + self._spread - (random.random() *
                                                            self._spread * 2)

        #The magnitude of the emitter's velocity
        magnitude = self._velocity.getMagnitude()

        #The emitter's position
        _position = Vector(self._position._x, self._position._y)

        #New velocity based off of the calculated angle and magnitude
        _velocity = fromAngle(angle, magnitude)

        #return our new Particle!
        return Particle(position=_position, velocity=_velocity)
Пример #7
0
 def random(self):
     """Get the next random number in the range [0.0, 1.0)."""
     return __random.random()