Animation function called on each frame, running prediction
964505
async function animate() {
  stats.begin();

  // Get image data from video element
  const image = tf.browser.fromPixels(video);
  let logits;
  // 'conv_preds' is the logits activation of MobileNet.
  const infer = () => mobilenet.infer(image, 'conv_preds');

  // Train class if one of the buttons is held down
  if (training != -1) {
    logits = infer();
    // Add current image to classifier
    classifier.addExample(logits, training);
  }

  // If the classifier has examples for any classes, make a prediction!
  const numClasses = classifier.getNumClasses();
  if (numClasses > 0) {
    logits = infer();

    const res = await classifier.predictClass(logits, TOPK);
    for (let i = 0; i < NUM_CLASSES; i++) {
      // Make the predicted class bold
      if (res.classIndex == i) {
        infoTexts[i].style.fontWeight = 'bold';
      } else {
        infoTexts[i].style.fontWeight = 'normal';
      }

      const classExampleCount = classifier.getClassExampleCount();
      // Update info text
      if (classExampleCount[i] > 0) {
        const conf = res.confidences[i] * 100;
        infoTexts[i].innerText = ` ${classExampleCount[i]} examples - ${conf}%`;
      }
    }
  }

  image.dispose();
  if (logits != null) {
    logits.dispose();
  }

  stats.end();

  requestAnimationFrame(animate);
}
418241
function nextFrame(fn) {
    let frame;
    let cancelFrame;

    if (window.requestAnimationFrame) {
        frame = requestAnimationFrame(() => {
            frame = requestAnimationFrame(fn);
        });
        cancelFrame = cancelAnimationFrame;
    } else {
        frame = setTimeout(fn, 26); // 16ms to simulate RAF, 10ms to ensure called after the frame.
        cancelFrame = clearTimeout;
    }

    return () => {
        if (frame) {
            cancelFrame(frame);
            frame = undefined;
        }
    };
}
378506
def _onMotion(self, evt):
        """"""

        x = evt.GetX()
        y = self.figure.bbox.height - evt.GetY()
        evt.Skip()
        FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=evt)
858494
function scheduleFrame(context, method) {
	method = context[method];

	return requestAnimationFrame(method.bind(context));
}
1104356
function startAnimation() {
    if (isIE8) {
      return;
    }
    // stop any already running animations
    stopAnimation();
    var fnc = function () {
      addClass(CTX.box, _const_class_prefix + '-loading');
      if (!isIE9 && typeof CTX.opt.loadingAnimation === 'number') {
        var index = 0;
        animationInt = setInterval(function () {
          addClass(animationChildren[index], _const_class_prefix + '-active');
          setTimeout(function () {
            removeClass(animationChildren[index], _const_class_prefix + '-active');
          }, CTX.opt.loadingAnimation);
          index = index >= animationChildren.length ? 0 : index += 1;
        }, CTX.opt.loadingAnimation);
      }
    };
    // set timeout to not show loading animation on fast connections
    animationTimeout = setTimeout(fnc, 500);
  }
941845
function Animation(startPosition, control0Range, control1Range, endPosition) {
  // each prefab is a plane
  var prefabGeometry = new THREE.PlaneGeometry(4.0, 4.0);
  var prefabCount = 100000;

  // create the buffer geometry with all the prefabs
  var geometry = new BAS.PrefabBufferGeometry(prefabGeometry, prefabCount);

  // ANIMATION

  // the actual duration of the animation is controlled by Animation.animate
  // this duration can be set to any value
  // let's set it to 1.0 to keep it simple
  var totalDuration = this.totalDuration = 1.0;

  geometry.createAttribute('aDelayDuration', 2, function(data, i, count) {
    // calculating the delay based on index will spread the prefabs over the 'timeline'
    data[0] = i / count * totalDuration;
    // all prefabs have the same animation duration, so we could store it as a uniform instead
    // storing it as an attribute takes more memory,
    // but for the sake of this demo it's easier in case we want to give each prefab a different duration
    data[1] = totalDuration;
  });

  // START & END POSITIONS

  // copy the start and end position for each prefab
  // these could be stored as uniforms as well, but we will keep them as attributes for the same reason as aDelayDuration
  geometry.createAttribute('aStartPosition', 3, function(data) {
    data[0] = startPosition.x;
    data[1] = startPosition.y;
    data[2] = startPosition.z;
  });

  geometry.createAttribute('aEndPosition', 3, function(data) {
    data[0] = endPosition.x;
    data[1] = endPosition.y;
    data[2] = endPosition.z;
  });

  // CONTROL POINTS

  // a temp point so we don't create exessive objects inside the factories (they will be called once for each prefab)
  var point = new THREE.Vector3();

  // while the start & end positions for each prefab are the same,
  // the control points are spread out within their respective ranges
  // because of this each prefab will have a different path

  geometry.createAttribute('aControl0', 3, function(data) {
    // pick a random point inside the given range for the first control point
    BAS.Utils.randomInBox(control0Range, point).toArray(data);
  });

  geometry.createAttribute('aControl1', 3, function(data) {
    // pick a random point inside the given range for the second control point
    BAS.Utils.randomInBox(control1Range, point).toArray(data);
  });

  // ROTATION

  // each prefab will get a random axis and an angle around that axis
  var axis = new THREE.Vector3();
  var angle = 0;

  geometry.createAttribute('aAxisAngle', 4, function(data) {
    axis.x = THREE.Math.randFloatSpread(2);
    axis.y = THREE.Math.randFloatSpread(2);
    axis.z = THREE.Math.randFloatSpread(2);
    axis.normalize();

    angle = Math.PI * THREE.Math.randInt(16, 32);

    data[0] = axis.x;
    data[1] = axis.y;
    data[2] = axis.z;
    data[3] = angle;
  });

  // COLOR

  // each prefab will get a psudo-random vertex color
  var color = new THREE.Color();
  var h, s, l;

  // we will use the built in VertexColors to give each prefab its own color
  // note you have to set Material.vertexColors to THREE.VertexColors for this to work
  geometry.createAttribute('color', 3, function(data, i, count) {
    // modulate the hue
    h = i / count;
    s = THREE.Math.randFloat(0.4, 0.6);
    l = THREE.Math.randFloat(0.4, 0.6);

    color.setHSL(h, s, l);
    color.toArray(data);
  });

  var material = new BAS.PhongAnimationMaterial({
    flatShading: true,
    vertexColors: THREE.VertexColors,
    side: THREE.DoubleSide,
    uniforms: {
      uTime: {type: 'f', value: 0}
    },
    uniformValues: {
      specular: new THREE.Color(0xff0000),
      shininess: 20
    },
    vertexFunctions: [
      // cubic_bezier defines the cubicBezier function used in the vertexPosition chunk
      BAS.ShaderChunk['cubic_bezier'],
      BAS.ShaderChunk['quaternion_rotation']
    ],
    // note we do not have to define 'color' as a uniform because THREE.js will do this for us
    // trying to define it here will throw a duplicate declaration error
    vertexParameters: [
      'uniform float uTime;',
      'attribute vec2 aDelayDuration;',
      'attribute vec3 aStartPosition;',
      'attribute vec3 aEndPosition;',
      'attribute vec3 aControl0;',
      'attribute vec3 aControl1;',
      'attribute vec4 aAxisAngle;'
    ],
    vertexInit: [
      // tProgress is in range 0.0 to 1.0
      // we want each prefab to restart at 0.0 if the progress is < 1.0, creating a continuous motion
      // the delay is added to the time uniform to spread the prefabs over the path
      'float tProgress = mod((uTime + aDelayDuration.x), aDelayDuration.y) / aDelayDuration.y;',

      'vec4 tQuat = quatFromAxisAngle(aAxisAngle.xyz, aAxisAngle.w * tProgress);'
    ],
    vertexPosition: [
      'transformed = rotateVector(tQuat, transformed);',
      // cubicBezier will return a vec3 on a cubic bezier curve defined by four points
      'transformed += cubicBezier(aStartPosition, aControl0, aControl1, aEndPosition, tProgress);'
    ]
  });

  THREE.Mesh.call(this, geometry, material);

  this.frustumCulled = false;
}
428948
def analyze(self, scratch, **kwargs):
        """"""
        results = Counter()
        for script in self.iter_scripts(scratch):
            gen = self.iter_blocks(script.blocks)
            name = 'start'
            level = None
            while name != '':
                if name in self.ANIMATION:
                    gen, count = self._check_animation(name, level, gen)
                    results.update(count)
                name, level, _ = next(gen, ('', 0, ''))
        return {'animation': results}
1101344
def reload_animations(self):
        
        self._update_time()
        self._animation_queue = list()
        self._tracked_gids = set()
        self._animation_map = dict()

        for gid, frame_data in self.get_animations():
            self._tracked_gids.add(gid)

            frames = list()
            for frame_gid, frame_duration in frame_data:
                image = self._get_tile_image_by_id(frame_gid)
                frames.append(AnimationFrame(image, frame_duration))

            # the following line is slow when loading maps, but avoids overhead when rendering
            # positions = set(self.tmx.get_tile_locations_by_gid(gid))

            # ideally, positions would be populated with all the known
            # locations of an animation, but searching for their locations
            # is slow. so it will be updated as the map is drawn.

            positions = set()
            ani = AnimationToken(positions, frames, self._last_time)
            self._animation_map[gid] = ani
            heappush(self._animation_queue, ani)
1224218
private void calculateAnimationProportions() {
        TRANSLATION_Y = sHeight * buttonDistanceY;
        TRANSLATION_X = sWidth * buttonDistanceX;

        anticipation = new AnticipateInterpolator(INTERPOLATOR_WEIGHT);
        overshoot = new OvershootInterpolator(INTERPOLATOR_WEIGHT);
    }
1018895
function percentBetweenKeyframes (keyframes, dt, numJoints) {
  var min
  var max
  Object.keys(keyframes).forEach(function (frame) {
    if (!min && !max) {
      min = frame
      max = frame
    } else {
      min = Math.min(min, frame)
      max = Math.max(max, frame)
    }
  })
  animationClock += dt / 1000
  var animationDuration = max - min
  if (animationClock > animationDuration) {
    animationClock %= animationDuration
  }
  // Find two closest keyframes
  var lowestKeyframe = null
  min = max = null
  var minJoints = []
  var maxJoints = []
  Object.keys(keyframes).sort().forEach(function (frame, index) {
    frame = Number(frame)
    if (index === 0) { lowestKeyframe = frame }
    if (frame <= lowestKeyframe + animationClock) {
      min = frame
      minJoints = keyframes['' + frame]
    }
    if (frame >= lowestKeyframe + animationClock && !max) {
      max = frame
      maxJoints = keyframes['' + frame]
    }
  })

  var percentBetweenKeyframes = (lowestKeyframe + animationClock - min) / (max - min)

  var interpolatedJoints = []
  for (var i = 0; i < numJoints; i++) {
    interpolatedJoints[i] = createMatrix()
    interpolate(interpolatedJoints[i], minJoints[i] || createMatrix(), maxJoints[i] || createMatrix(), percentBetweenKeyframes)
  }

  // We store our dual quaternion vectors and later push them to the GPU for duql quaternion blending
  var interpolatedRotQuaternions = []
  var interpolatedTransQuaternions = []

  // TODO: Just got dual quaternion skinning working! Code is a mess need to clean. Was throwing everything at the wall on this one..
  // TODO: Don't convert keyframe matrices into dual quaternions every single frame. Only need to do it once
  // TODO: Rename the variables
  interpolatedJoints.forEach(function (joint, index) {
    // Create our lower keyframe dual quaternion
    joint = minJoints[index]
    var rotationMatrix = mat3FromMat4([], joint)
    var rotationQuat = quatFromMat3([], rotationMatrix)
    var transVec = [joint[12], joint[13], joint[14], 0]
    var transQuat = quatScale([], quatMultiply([], transVec, rotationQuat), 0.5)

    // Create our upper keyframe dual quaternion
    var joint2 = maxJoints[index]
    var rotationMatrix2 = mat3FromMat4([], joint2)
    var rotationQuat2 = quatFromMat3([], rotationMatrix2)
    var transVec2 = [joint2[12], joint2[13], joint2[14], 0]
    var transQuat2 = quatScale([], quatMultiply([], transVec2, rotationQuat2), 0.5)

    // Interpolate our upper and lower keyframe dual quaternions using dual quaternion linear blending
    rotationQuat = quatAdd([], quatScale([], rotationQuat, 1 - percentBetweenKeyframes), quatScale([], rotationQuat2, percentBetweenKeyframes))
    transQuat = quatAdd([], quatScale([], transQuat, 1 - percentBetweenKeyframes), quatScale([], transQuat2, percentBetweenKeyframes))

    interpolatedRotQuaternions.push(rotationQuat)
    interpolatedTransQuaternions.push(transQuat)
  })

  return {
    interpolatedJoints: interpolatedJoints,
    interpolatedRotQuaternions: interpolatedRotQuaternions,
    interpolatedTransQuaternions: interpolatedTransQuaternions
  }
}
288673
function processAnimation(clip, root) {
      if (!outputJSON.animations) {
        outputJSON.animations = [];
      }

      var channels = [];
      var samplers = [];

      for (var i = 0; i < clip.tracks.length; ++i) {
        var track = clip.tracks[i];
        var trackBinding = THREE.PropertyBinding.parseTrackName(track.name);
        var trackNode = THREE.PropertyBinding.findNode(
          root,
          trackBinding.nodeName
        );
        var trackProperty = PATH_PROPERTIES[trackBinding.propertyName];

        if (trackBinding.objectName === 'bones') {
          if (trackNode.isSkinnedMesh === true) {
            trackNode = trackNode.skeleton.getBoneByName(
              trackBinding.objectIndex
            );
          } else {
            trackNode = undefined;
          }
        }

        if (!trackNode || !trackProperty) {
          console.warn(
            'THREE.GLTFExporter: Could not export animation track "%s".',
            track.name
          );
          return null;
        }

        var inputItemSize = 1;
        var outputItemSize = track.values.length / track.times.length;

        if (trackProperty === PATH_PROPERTIES.morphTargetInfluences) {
          if (
            trackNode.morphTargetInfluences.length !== 1 &&
            trackBinding.propertyIndex !== undefined
          ) {
            console.warn(
              'THREE.GLTFExporter: Skipping animation track "%s". ' +
                'Morph target keyframe tracks must target all available morph targets ' +
                'for the given mesh.',
              track.name
            );
            continue;
          }

          outputItemSize /= trackNode.morphTargetInfluences.length;
        }

        var interpolation;

        // @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE

        // Detecting glTF cubic spline interpolant by checking factory method's special property
        // GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return
        // valid value from .getInterpolation().
        if (
          track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ===
          true
        ) {
          interpolation = 'CUBICSPLINE';

          // itemSize of CUBICSPLINE keyframe is 9
          // (VEC3 * 3: inTangent, splineVertex, and outTangent)
          // but needs to be stored as VEC3 so dividing by 3 here.
          outputItemSize /= 3;
        } else if (track.getInterpolation() === THREE.InterpolateDiscrete) {
          interpolation = 'STEP';
        } else {
          interpolation = 'LINEAR';
        }

        samplers.push({
          input: processAccessor(
            new THREE.BufferAttribute(track.times, inputItemSize)
          ),
          output: processAccessor(
            new THREE.BufferAttribute(track.values, outputItemSize)
          ),
          interpolation: interpolation
        });

        channels.push({
          sampler: samplers.length - 1,
          target: {
            node: nodeMap.get(trackNode),
            path: trackProperty
          }
        });
      }

      outputJSON.animations.push({
        name: clip.name || 'clip_' + outputJSON.animations.length,
        samplers: samplers,
        channels: channels
      });

      return outputJSON.animations.length - 1;
    }
1148901
function update() {
  el.style.transform = 'scale3d(' + s1(x) + ', ' + s2(y) + ', 1)';

  requestAnimationFrame(update);
}
685824
def _update_fps(self, event):
        """"""
        self._frame_count += 1
        diff = time() - self._basetime
        if (diff > self._fps_window):
            self._fps = self._frame_count / diff
            self._basetime = time()
            self._frame_count = 0
            self._fps_callback(self.fps)
1234257
function _renderFrame(time) {
            var stage = _stages[_state].stage;
            // update all game objects
            me.game.update(time, stage);
            // render all game objects
            me.game.draw(stage);
            // schedule the next frame update
            if (_animFrameId !== -1) {
                _animFrameId = window.requestAnimationFrame(_renderFrame);
            }
        }
1079188
function update(dt) {
         var duration = 0,
             now = me.timer.getTime(),
             result = false;

         if (this._lastUpdate !== now) {
           this._lastUpdate = now;
           this.animations.forEach(function (anim) {
             anim.dt += dt;
             duration = anim.cur.duration;

             while (anim.dt >= duration) {
               anim.dt -= duration;
               anim.idx = (anim.idx + 1) % anim.frames.length;
               anim.cur = anim.frames[anim.idx];
               duration = anim.cur.duration;
               result = true;
             }
           });
         }

         return result;
       }
241989
function animateElement(element, animation = '', callback = false) {
    if (!element || animation === '') {
        return false;
    }
    if (animation == 'none') {
        if (utils.isFunction(callback))
            callback()
        return false;
    }
    const animationNames = animation.split(' ')
    each(animationNames, (name) => {
        addClass(element, 'g'+name)
    })
    addEvent(animationEnd, {
        onElement: element,
        avoidDuplicate: false,
        once: true,
        withCallback: (event, target) => {
            each(animationNames, (name) => {
                removeClass(target, 'g' + name)
            })
            if (utils.isFunction(callback))
                callback()
        }
    })
}
609332
function Animation(from, to, duration) {
  this._from = from;
  this._to = to;
  this._duration = duration;
  this._left = duration;
  this._start = Date.now();
  this._looping = false;
  this._finished = false;
}