Skip to content

Commit

Permalink
Added random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
fgatti675 committed Feb 28, 2024
1 parent cdf5ff1 commit cafe728
Show file tree
Hide file tree
Showing 2 changed files with 2,167 additions and 1,842 deletions.
15 changes: 11 additions & 4 deletions lib/src/NeatGradient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class NeatGradient implements NeatController {
private sizeObserver: ResizeObserver;
private sceneState: SceneState;

constructor(config: NeatConfig & { ref: HTMLCanvasElement, resolution?: number }) {
constructor(config: NeatConfig & { ref: HTMLCanvasElement, resolution?: number, seed?: number }) {

const {
ref,
Expand All @@ -97,7 +97,8 @@ export class NeatGradient implements NeatController {
wireframe = false,
backgroundColor = "#FFFFFF",
backgroundAlpha = 1.0,
resolution = 1
resolution = 1,
seed
} = config;


Expand Down Expand Up @@ -125,8 +126,7 @@ export class NeatGradient implements NeatController {

this.sceneState = this._initScene(resolution);


let tick = 0;
let tick = seed !== undefined ? seed : getElapsedSecondsInLastHour();
const render = () => {

const { renderer, camera, scene, meshes } = this.sceneState;
Expand Down Expand Up @@ -811,3 +811,10 @@ const addNeatLink = (ref: HTMLCanvasElement) => {
setLinkStyles(link);
ref.parentElement?.appendChild(link);
}

function getElapsedSecondsInLastHour() {
const now = new Date();
const minutes = now.getMinutes();
const seconds = now.getSeconds();
return (minutes * 60) + seconds;
}
Loading

0 comments on commit cafe728

Please sign in to comment.