<commit_before>/**@
* #SpriteAnimation
* @category Animation
* @trigger AnimationEnd - When the animation finishes - { reelId: <reelID> }
* @trigger FrameChange - Each frame change - { reelId: <reelID>, frameNumber: <New frame's number> }
*
* Used to animate sprites by treating a sprite map as a set of animation frames.
* Must be applied to an entity that has a sprite-map component.
*
* @see crafty.sprite
*/
Crafty.c("SpriteAnimation", {
	/**@
	* #._reels
	* @comp SpriteAnimation
	*
	* A map in which the keys are the names assigned to animations defined using
	* the component (also known as reelIDs), and the values are objects describing
	* the animation and its state.
	*/
	_reels: null,

	/**@
	* #._currentReelId
	* @comp SpriteAnimation
	*
	* The reelID of the currently active reel (which is one of the elements in `this._reels`).
	* This value is `null` if no reel is active. Some of the component's actions can be invoked
	* without specifying a reel, in which case they will work on the active reel.
	*/
	_currentReelId: null,

	/**@
	* #._isPlaying
	* @comp SpriteAnimation
	*
	* Whether or not an animation is currently playing.
	*/
	_isPlaying: false,

	init: function () {
		this._reels = {};
	},

	/**@
	* #.animate
	* @comp SpriteAnimation
	* @sign public this .animate(String reelId, Number fromX, Number y, Number toX)
	* @param reelId - ID of the animation reel being created
	* @param fromX - Starting `x` position on the sprite map (x's unit is the horizontal size of the sprite in the sprite map).
	* @param y - `y` position on the sprite map (y's unit is the horizontal size of the sprite in the sprite map). Remains constant through the animation.
	* @param toX - End `x` position on the sprite map. This can be smaller than `fromX`, in which case the frames will play in descending order.
	* @sign public this .animate(String reelId, Array frames)
	* @param reelId - ID of the animation reel being created
	* @param frames - Array of arrays containing the `x` and `y` values of successive frames: [[x1,y1],[x2,y2],...] (the values are in the unit of the sprite map's width/height respectively).
	*
	* Method to setup animation reels. Animation works by changing the sprites over
	* a duration. Only works for sprites built with the Crafty.sprite methods.
	* See the Tween component for animation of 2D properties.
	*
	* To setup an animation reel, pass the name of the reel (used to identify the reel and play it later), and either an
	* array of absolute sprite positions or the start x on the sprite map, the y on the sprite map and then the end x on the sprite map.
	*
	* @example
	* ~~~
	*\/\/ Define a sprite-map component
	* Crafty.sprite(16, "images/sprite.png", {
	*     PlayerSprite: [0,0]
	* });
	*
	* \/\/ Define an animation on the second row of the sprite map (y=1) from the left most sprite (fromX = 0) to the fourth sprite on that row (toX = 3)
	* Crafty.e("2D, DOM, SpriteAnimation, PlayerSprite").animate('PlayerRunning', 0, 1, 3);
	*
	* \/\/ This is the same animation definition, but using the alternative method
	* Crafty.e("2D, DOM, SpriteAnimation, PlayerSprite").animate('PlayerRunning', [[0, 1], [1, 1], [2, 1], [3, 1]]);
	* ~~~
	*/
	animate: function (reelId, fromX, y, toX) {
		var reel, i, tile, tileh, pos;

		// Get the dimensions of a single frame, as defind in Sprite component.
		tile = this.__tile + parseInt(this.__padding[0] || 0, 10);
		tileh = this.__tileh + parseInt(this.__padding[1] || 0, 10);

		reel = {
			frames: [],
			cyclesPerFrame: undefined, // This gets defined when calling play(...)
			currentFrameNumber: 0,
			cycleNumber: 0,
			repeatInfinitly: false,
			repeatsRemaining: 0
		}

		// @sign public this .animate(String reelId, Number fromX, Number y, Number toX)
		if (typeof fromX === "number") {
			i = fromX;
			if (toX > fromX) {<commit_msg>Slight formatting fixes for the docs<commit_after>/**@
* #SpriteAnimation
* @category Animation
* @trigger AnimationEnd - When the animation finishes - { reelId: <reelID> }
* @trigger FrameChange - Each frame change - { reelId: <reelID>, frameNumber: <New frame's number> }
*
* Used to animate sprites by treating a sprite map as a set of animation frames.
* Must be applied to an entity that has a sprite-map component.
*
* @see crafty.sprite
*/
Crafty.c("SpriteAnimation", {
	/**@
	* #._reels
	* @comp SpriteAnimation
	*
	* A map in which the keys are the names assigned to animations defined using
	* the component (also known as reelIDs), and the values are objects describing
	* the animation and its state.
	*/
	_reels: null,

	/**@
	* #._currentReelId
	* @comp SpriteAnimation
	*
	* The reelID of the currently active reel (which is one of the elements in `this._reels`).
	* This value is `null` if no reel is active. Some of the component's actions can be invoked
	* without specifying a reel, in which case they will work on the active reel.
	*/
	_currentReelId: null,

	/**@
	* #._isPlaying
	* @comp SpriteAnimation
	*
	* Whether or not an animation is currently playing.
	*/
	_isPlaying: false,

	init: function () {
		this._reels = {};
	},

	/**@
	* #.animate
	* @comp SpriteAnimation
	* @sign public this .animate(String reelId, Number fromX, Number y, Number toX)
	* @param reelId - ID of the animation reel being created
	* @param fromX - Starting `x` position on the sprite map (x's unit is the horizontal size of the sprite in the sprite map).
	* @param y - `y` position on the sprite map (y's unit is the horizontal size of the sprite in the sprite map). Remains constant through the animation.
	* @param toX - End `x` position on the sprite map. This can be smaller than `fromX`, in which case the frames will play in descending order.
	* @sign public this .animate(String reelId, Array frames)
	* @param reelId - ID of the animation reel being created
	* @param frames - Array of arrays containing the `x` and `y` values of successive frames: [[x1,y1],[x2,y2],...] (the values are in the unit of the sprite map's width/height respectively).
	*
	* Method to setup animation reels. Animation works by changing the sprites over
	* a duration. Only works for sprites built with the Crafty.sprite methods.
	* See the Tween component for animation of 2D properties.
	*
	* To setup an animation reel, pass the name of the reel (used to identify the reel and play it later), and either an
	* array of absolute sprite positions or the start x on the sprite map, the y on the sprite map and then the end x on the sprite map.
	*
	* @example
	* ~~~
	*\/\/ Define a sprite-map component
	* Crafty.sprite(16, "images/sprite.png", {
	*     PlayerSprite: [0,0]
	* });
	*
	* \/\/ Define an animation on the second row of the sprite map (y = 1)
	* \/\/ from the left most sprite (fromX = 0) to the fourth sprite
	* \/\/ on that row (toX = 3)
	* Crafty.e("2D, DOM, SpriteAnimation, PlayerSprite").animate('PlayerRunning', 0, 1, 3);
	*
	* \/\/ This is the same animation definition, but using the alternative method
	* Crafty.e("2D, DOM, SpriteAnimation, PlayerSprite").animate('PlayerRunning', [[0, 1], [1, 1], [2, 1], [3, 1]]);
	* ~~~
	*/
	animate: function (reelId, fromX, y, toX) {
		var reel, i, tile, tileh, pos;

		// Get the dimensions of a single frame, as defind in Sprite component.
		tile = this.__tile + parseInt(this.__padding[0] || 0, 10);
		tileh = this.__tileh + parseInt(this.__padding[1] || 0, 10);

		reel = {
			frames: [],
			cyclesPerFrame: undefined, // This gets defined when calling play(...)
			currentFrameNumber: 0,
			cycleNumber: 0,
			repeatInfinitly: false,
			repeatsRemaining: 0
		}

		// @sign public this .animate(String reelId, Number fromX, Number y, Number toX)
		if (typeof fromX === "number") {
			i = fromX;
			if (toX > fromX) {
{'fraction_non_alphanumeric': 0.1124237310138907, 'fraction_numerical': 0.009347007659353498, 'mean_word_length': 3.5802615933412603, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1407934', 'n_tokens_mistral': 2629, 'n_tokens_neox': 2400, 'n_words': 1038}