Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a825299
commit 954858e
Showing
28 changed files
with
374 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
engine/src/Options/Classes/Gradients/AnimatableGradient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { AnimatableGradientColor } from "./AnimatableGradientColor"; | ||
import { GradientAngle } from "./GradientAngle"; | ||
import { GradientType } from "../../../Enums/Types/GradientType"; | ||
import type { IAnimatableGradient } from "../../Interfaces/IAnimatableGradient"; | ||
import type { IOptionLoader } from "../../Interfaces/IOptionLoader"; | ||
import type { RecursivePartial } from "../../../Types/RecursivePartial"; | ||
|
||
export class AnimatableGradient implements IAnimatableGradient, IOptionLoader<IAnimatableGradient> { | ||
angle: GradientAngle; | ||
colors: AnimatableGradientColor[]; | ||
type: GradientType; | ||
|
||
constructor() { | ||
this.angle = new GradientAngle(); | ||
this.colors = []; | ||
this.type = GradientType.random; | ||
} | ||
|
||
load(data?: RecursivePartial<IAnimatableGradient>): void { | ||
if (!data) { | ||
return; | ||
} | ||
|
||
this.angle.load(data.angle); | ||
|
||
if (data.colors !== undefined) { | ||
this.colors = data.colors.map((s) => { | ||
const tmp = new AnimatableGradientColor(); | ||
|
||
tmp.load(s); | ||
|
||
return tmp; | ||
}); | ||
} | ||
|
||
if (data.type !== undefined) { | ||
this.type = data.type; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
engine/src/Options/Classes/Gradients/AnimatableGradientColor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AnimatableColor } from "../AnimatableColor"; | ||
import { GradientColorOpacity } from "./GradientColorOpacity"; | ||
import type { IAnimatableGradientColor } from "../../Interfaces/IOptionsGradient"; | ||
import type { IOptionLoader } from "../../Interfaces/IOptionLoader"; | ||
import type { RecursivePartial } from "../../../Types/RecursivePartial"; | ||
|
||
export class AnimatableGradientColor implements IAnimatableGradientColor, IOptionLoader<IAnimatableGradientColor> { | ||
stop; | ||
value; | ||
opacity?: GradientColorOpacity; | ||
|
||
constructor() { | ||
this.stop = 0; | ||
this.value = new AnimatableColor(); | ||
} | ||
|
||
load(data?: RecursivePartial<IAnimatableGradientColor>): void { | ||
if (!data) { | ||
return; | ||
} | ||
|
||
if (data.stop !== undefined) { | ||
this.stop = data.stop; | ||
} | ||
|
||
this.value = AnimatableColor.create(this.value, data.value); | ||
|
||
if (data.opacity !== undefined) { | ||
this.opacity = new GradientColorOpacity(); | ||
|
||
if (typeof data.opacity === "number") { | ||
this.opacity.value = data.opacity; | ||
} else { | ||
this.opacity.load(data.opacity); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.