Library design

Rutger via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 12 21:11:37 PDT 2014


I'm trying to create a minimal tweening library in D based on the
commonly used easing equations by Robert Penner
(http://www.robertpenner.com/easing/).
One of the goals with the design of the library is that any
numeric type should be tweenable.(The user of the library
shouldn't have to do any casting of their own etc) Now how do I
go about and design a data structure that can take either floats,
ints or doubles, store them and modify them?

This is what I hacked together earlier today:


abstract class TweenWrapper{
		
}


class Tween(T) : TweenWrapper{
		
     		T owner;
		
		string[] members;
		
		/** Duration in milliseconds */
		int duration;
		
		/** Elapsed time in milliseconds */
		int elapsedTime;
		
		bool isComplete;
		
		/** Type of easing */
		EasingType easingType;
			
}

TweenWrapper is just what it sounds like, a wrapper so I don't
have to specify any type for the container holding the Tween
objects(DList!TweenWrapper).

__traits(getMember, owner, members[0]) =
valueReturnedFromEasingFunction;
Was How I planned to use this class.. but you know, compile time
only.


Let me know if this isn't enough to go on.
Is what I'm asking even possible(the easy way) in D?


TL;DR
Help me make D Dynamic!


More information about the Digitalmars-d-learn mailing list