Add BackgroundColorAnimation and AlphaAnimation

This commit is contained in:
pengfei.zhou
2021-09-07 18:33:25 +08:00
committed by osborn
parent e51749e644
commit d7d19b17d0
11 changed files with 815 additions and 316 deletions

View File

@@ -1,5 +1,6 @@
import { Color } from "../util/color";
import { Modeling, Model } from "../util/types";
export declare type AnimatedKey = "translationX" | "translationY" | "scaleX" | "scaleY" | "rotation" | "pivotX" | "pivotY" | "rotationX" | "rotationY";
export declare type AnimatedKey = "translationX" | "translationY" | "scaleX" | "scaleY" | "rotation" | "pivotX" | "pivotY" | "rotationX" | "rotationY" | "backgroundColor" | "alpha";
export declare enum RepeatMode {
RESTART = 1,
REVERSE = 2
@@ -107,6 +108,9 @@ export declare class TranslationAnimation extends Animation {
set toTranslationY(v: number);
get toTranslationY(): number;
}
/**
* Rotation range is [0..2]
*/
export declare class RotationAnimation extends Animation {
private rotationChaneable;
constructor();
@@ -115,6 +119,9 @@ export declare class RotationAnimation extends Animation {
set toRotation(v: number);
get toRotation(): number;
}
/**
* Rotation range is [0..2]
*/
export declare class RotationXAnimation extends Animation {
private rotationChaneable;
constructor();
@@ -123,6 +130,9 @@ export declare class RotationXAnimation extends Animation {
set toRotation(v: number);
get toRotation(): number;
}
/**
* Rotation range is [0..2]
*/
export declare class RotationYAnimation extends Animation {
private rotationChaneable;
constructor();
@@ -131,6 +141,25 @@ export declare class RotationYAnimation extends Animation {
set toRotation(v: number);
get toRotation(): number;
}
export declare class BackgroundColorAnimation extends Animation {
private backgroundColorChangeable;
constructor();
set fromColor(color: Color);
get fromColor(): Color;
set toColor(v: Color);
get toColor(): Color;
}
/**
* Alpha range is [0..1]
*/
export declare class AlphaAnimation extends Animation {
private opacityChangeable;
constructor();
set from(v: number);
get from(): number;
set to(v: number);
get to(): number;
}
export declare class AnimationSet implements IAnimation {
private animations;
private _duration;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Color } from "../util/color";
import { uniqueId } from "../util/uniqueId";
export var RepeatMode;
(function (RepeatMode) {
@@ -172,6 +173,9 @@ export class TranslationAnimation extends Animation {
return this.translationYChangeable.toValue;
}
}
/**
* Rotation range is [0..2]
*/
export class RotationAnimation extends Animation {
constructor() {
super();
@@ -195,6 +199,9 @@ export class RotationAnimation extends Animation {
return this.rotationChaneable.toValue;
}
}
/**
* Rotation range is [0..2]
*/
export class RotationXAnimation extends Animation {
constructor() {
super();
@@ -218,6 +225,9 @@ export class RotationXAnimation extends Animation {
return this.rotationChaneable.toValue;
}
}
/**
* Rotation range is [0..2]
*/
export class RotationYAnimation extends Animation {
constructor() {
super();
@@ -241,6 +251,55 @@ export class RotationYAnimation extends Animation {
return this.rotationChaneable.toValue;
}
}
export class BackgroundColorAnimation extends Animation {
constructor() {
super();
this.backgroundColorChangeable = {
key: "backgroundColor",
fromValue: Color.TRANSPARENT._value,
toValue: Color.TRANSPARENT._value,
};
this.changeables.set("backgroundColor", this.backgroundColorChangeable);
}
set fromColor(color) {
this.backgroundColorChangeable.fromValue = color._value;
}
get fromColor() {
return new Color(this.backgroundColorChangeable.fromValue);
}
set toColor(v) {
this.backgroundColorChangeable.toValue = v._value;
}
get toColor() {
return new Color(this.backgroundColorChangeable.toValue);
}
}
/**
* Alpha range is [0..1]
*/
export class AlphaAnimation extends Animation {
constructor() {
super();
this.opacityChangeable = {
key: "alpha",
fromValue: 1,
toValue: 1,
};
this.changeables.set("alpha", this.opacityChangeable);
}
set from(v) {
this.opacityChangeable.fromValue = v;
}
get from() {
return this.opacityChangeable.fromValue;
}
set to(v) {
this.opacityChangeable.toValue = v;
}
get to() {
return this.opacityChangeable.toValue;
}
}
export class AnimationSet {
constructor() {
this.animations = [];