Skip to content

Commit 410711c

Browse files
committed
Import the animatronic project
1 parent 39d86e2 commit 410711c

22 files changed

Lines changed: 1618 additions & 1 deletion

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
7+
# BlueJ files
8+
*.ctxt
9+
10+
# Mobile Tools for Java (J2ME)
11+
.mtj.tmp/
12+
13+
# Package Files #
14+
*.jar
15+
*.war
16+
*.ear
17+
*.zip
18+
*.tar.gz
19+
*.rar
20+
21+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22+
hs_err_pid*
23+
24+
### IntelliJ IDEA ###
25+
.idea
26+
*.iws
27+
*.iml
28+
*.ipr
29+
out/
30+
!**/src/main/**/out/
31+
!**/src/test/**/out/
32+
33+
### Gradle ###
34+
.gradle
35+
build/
36+
!gradle/wrapper/gradle-wrapper.jar
37+
!**/src/main/**/build/
38+
!**/src/test/**/build/

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
language: java
2+
install: true

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,87 @@
11
# Animatronics
22

3+
[![License](https://img.shields.io/badge/License-APL%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
4+
[![Travis CI](https://travis-ci.org/tbressler/java-animatronics.svg?branch=master)](https://travis-ci.org/tbressler/java-animatronics)
5+
36
A very simple and low-level animation library for your Java project.
47

8+
The name *Animatronic* is a homage to mechatronic puppets which are often used in films and in theme park attractions.
9+
10+
## Usage
11+
12+
The library requires JDK 9 or higher.
13+
14+
### Animate a simple value
15+
16+
```Java
17+
18+
// Initialize and configure your animation (timeline).
19+
AnimatronicDouble animation = new AnimatronicDouble(1.0d)
20+
.keyframe(1.3d, 5000, Easings.easeInOutBack())
21+
.keyframe(5.4d, 3000, Easings.easeInOutCubic())
22+
.play();
23+
24+
// ...
25+
26+
// Start the animation at some point in time.
27+
animation.play();
28+
29+
// ...
30+
31+
// Use the current (interpolated) value when drawing.
32+
double currentValue = animation.getValue();
33+
34+
```
35+
36+
### Animate any object
37+
38+
Use the abstract class ```Animatronic<T>``` in order to animate any object you want. Simply create a class which extends ```Animatronic``` and implement the ```calculateValueInBetween()``` method. The method calculates the interpolated value with the given factor. You can use the helper method ```calculateValue()``` to calculate the interpolated value without any hustle.
39+
40+
A good example is the ```AnimatronicPoint2D``` class:
41+
42+
```Java
43+
44+
public class AnimatronicPoint2D extends Animatronic<Point2D> {
45+
46+
// ...
47+
48+
@Override
49+
protected Point2D calculateValueInBetween(Point2D lastValue, Point2D nextValue, double factor) {
50+
return new Point2D.Double(
51+
// Calculate the interpolated coordinates:
52+
calculateValue(lastValue.getX(), nextValue.getX(), factor),
53+
calculateValue(lastValue.getY(), nextValue.getY(), factor)
54+
);
55+
}
56+
}
57+
58+
```
59+
60+
The library has different default implementations:
61+
62+
* Double with ```AnimatronicDouble```
63+
* Float with ```AnimatronicFloat```
64+
* Integer with ```AnimatronicInteger```
65+
* Color with ```AnimatronicColor```
66+
* Point2D with ```AnimatronicPoint2D```
67+
68+
69+
### Easing functions
70+
71+
The library comes with different predefined easing functions.
72+
73+
```Java
74+
75+
Easing e1 = Easings.easeInBack();
76+
Easing e2 = Easings.easeInOutCubic();
77+
// ... and so on.
78+
79+
```
80+
581
## License
682

783
```
8-
Copyright 2021 Tobias Bressler
84+
Copyright 2021 Tobias Breßler
985
1086
Licensed under the Apache License, Version 2.0 (the "License");
1187
you may not use this file except in compliance with the License.

build.gradle

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
group 'de.tbressler.animatronics'
2+
version '1.0.0'
3+
4+
apply plugin: 'java'
5+
apply plugin: 'maven'
6+
7+
sourceCompatibility = '9'
8+
targetCompatibility = '9'
9+
10+
repositories {
11+
mavenLocal()
12+
mavenCentral()
13+
}
14+
15+
dependencies {
16+
17+
// JUnit and tests:
18+
testCompile 'junit:junit:4.13.1'
19+
testCompile 'org.mockito:mockito-all:1.10.19'
20+
21+
}
22+
23+
jar {
24+
25+
manifest {
26+
attributes 'Implementation-Title': 'Animatronics Library',
27+
'Implementation-Version': archiveVersion,
28+
'Implementation-Vendor': 'Tobias Breßler'
29+
}
30+
31+
from {
32+
configurations.compile.collect {
33+
it.isDirectory() ? it : zipTree(it)
34+
}
35+
}
36+
37+
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'java-animatronics'

0 commit comments

Comments
 (0)