File: animationImpl.d

package info (click to toggle)
projectl 1.001.dfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,720 kB
  • ctags: 5
  • sloc: xml: 57; makefile: 32
file content (114 lines) | stat: -rw-r--r-- 2,628 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
module util.animationImpl;
private import std.math;
private import util.animation;
private import util.parts;
private import util.matrix;


public class Swing:Animation{
	public:
	uint degType;
	double amp;
	double alpha;
	double delay;
	public this(int span ,uint degType ,double amp ,double alpha = 0.0 ,int delay = 0 ,bool repeat = false){
		super(span ,repeat);
		this.degType = degType;
		this.amp = amp;
		this.alpha = alpha;
		this.delay = delay;
	}
	public override void run(){
		super.run();
		if(parts !is null && parts.exists){
			parts.rotate(degType ,sin(((count + delay) % span) * PI * 2.0 / span) * amp , alpha);
		}
	}

}

public class RotateTo:Animation{
	public:
	double dDeg;
	double targetDeg;
	uint degType;
	double alpha;
	public this(int span ,uint degType ,double targetDeg ,double alpha = 0.0  ,bool repeat = false){
		super(span ,repeat);
		this.degType = degType;
		this.targetDeg = targetDeg;
		this.dDeg = 0;
		this.alpha = alpha;
	}
	public override void set(Parts parts){
		super.set(parts);
		if(abs(span - count) > (1e-6)){
			dDeg = (targetDeg - *parts.pDeg(degType)) / cast(double)(span - count);
		}
	}
	public override void run(){
		super.run();
		if(parts !is null && parts.exists){
			parts.rotate(degType ,dDeg , alpha);
		}
	}

}
public class Rotate:Animation{
	public:
	double dDeg;
	double alpha;
	uint degType;
	public this(int span ,uint degType ,double dDeg ,double alpha = 0.0 ,bool repeat = false){
		super(span ,repeat);
		this.degType = degType;
		this.dDeg = dDeg;
		this.alpha = alpha;
	}
	public override void run(){
		super.run();
		if(parts !is null && parts.exists){
			parts.rotate(degType ,dDeg , alpha);
		}
	}
}
public class RotateAll:Animation{
	public:
	Matrix d;
	public this(int span ,Matrix d ,bool repeat = false){
		super(span ,repeat);
		this.d = cast(Matrix)d.clone();
	}
	public override void run(){
		super.run();
		if(parts !is null && parts.exists){
			parts.rotateAll(d);
		}
	}
}

public class ExtendTo:Animation{
	public:
	double dDist;
	double targetDist;
	double alpha;
	public this(int span ,double targetDist ,double alpha = 0.0  ,bool repeat = false){
		super(span ,repeat);
		this.targetDist = targetDist;
		this.dDist = 0;
		this.alpha = alpha;
	}
	public override void set(Parts parts){
		super.set(parts);
		if(abs(span - count) > (1e-6)){
			dDist = (targetDist - parts.dist) / cast(double)(span - count);
		}
	}
	public override void run(){
		super.run();
		if(parts !is null && parts.exists){
			parts.dist += dDist;
		}
	}

}