<commit_before>/**
	General interpolation class. This example moves myEntity to the upper left corner
	over the course of two seconds, after which the Tween component removes itself from 
	myEntity. Tweens require the TweeningSystem to be active.

		var pos = myEntity.get(Position);
		var tween = new Tween(pos, { x:0, y:0 }, 2);
		tween.destroyComponent = true;
		myEntity.add(t);

*/
package flaxen.component;

import ash.core.Engine;
import flaxen.common.Easing;
import flaxen.common.LoopType;
import flaxen.core.Log;

class Tween
{
	public static var created:Int = 0;

	public var complete:Bool = false;
	public var running:Bool = false;
	public var source:Dynamic;
	public var target:Dynamic;
	public var ranges:Array<Float>;
	public var starts:Array<Float>;
	public var props:Array<String>;
	public var easing:EasingFunction;
	public var elapsed:Float = 0;
	public var loop:LoopType; // Can set after creating tween
	public var optional:Float = 1.70158;
	public var duration:Float;
	public var destroyEntity:Bool = false;
	public var destroyComponent:Bool = false;
	public var fields:Array<String>;
	public var name:String; // optional object name for logging
	public var stopAfterLoops:Int = 0; // Only if loop is not None; if 0 assumed infinite
	public var loopCount(default, null):Int = 0;

	public function new(source:Dynamic, target:Dynamic, duration:Float, 
		easing:EasingFunction = null, autoStart:Bool = true)
	{
		this.source = source;
		this.target = target;
		this.duration = duration;
		Log.assert(duration > 0);
		this.easing = (easing == null ? Easing.linearTween : easing);
		this.loop = LoopType.None;
		this.name = "tween"  + Std.string(++created);
		<commit_msg>Added support for looping Tween from constructor<commit_after>/**
	General interpolation class. This example moves myEntity to the upper left corner
	over the course of two seconds, after which the Tween component removes itself from 
	myEntity. Tweens require the TweeningSystem to be active.

		var pos = myEntity.get(Position);
		var tween = new Tween(pos, { x:0, y:0 }, 2);
		tween.destroyComponent = true;
		myEntity.add(t);

*/
package flaxen.component;

import ash.core.Engine;
import flaxen.common.Easing;
import flaxen.common.LoopType;
import flaxen.core.Log;

class Tween
{
	public static var created:Int = 0;

	public var complete:Bool = false;
	public var running:Bool = false;
	public var source:Dynamic;
	public var target:Dynamic;
	public var ranges:Array<Float>;
	public var starts:Array<Float>;
	public var props:Array<String>;
	public var easing:EasingFunction;
	public var elapsed:Float = 0;
	public var loop:LoopType; // Can set after creating tween
	public var optional:Float = 1.70158;
	public var duration:Float;
	public var destroyEntity:Bool = false;
	public var destroyComponent:Bool = false;
	public var fields:Array<String>;
	public var name:String; // optional object name for logging
	public var stopAfterLoops:Int = 0; // Only if loop is not None; if 0 assumed infinite
	public var loopCount(default, null):Int = 0;

	public function new(source:Dynamic, target:Dynamic, duration:Float, 
		easing:EasingFunction = null, loop:LoopType = null, autoStart:Bool = true)
	{
		this.source = source;
		this.target = target;
		this.duration = duration;
		Log.assert(duration > 0);
		this.easing = (easing == null ? Easing.linearTween : easing);
		this.loop = (loop == null ? LoopType.None : loop);
		this.name = "tween"  + Std.string(++created);
		
{'fraction_non_alphanumeric': 0.10037604859704946, 'fraction_numerical': 0.008678044547295342, 'mean_word_length': 4.5954692556634305, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5915576', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1069, 'n_words': 361}