speice.io/posts/2023/06/flam3/2c-final.ts

64 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-07-01 00:38:15 -04:00
import {
Flame,
Transform,
julia,
transform1Weight,
2023-07-02 15:49:36 -04:00
transform1,
2023-07-01 00:38:15 -04:00
transform2Weight,
transform3Weight,
2023-07-02 15:49:36 -04:00
transform3,
2023-07-02 15:30:56 -04:00
render,
2023-07-01 00:38:15 -04:00
} from "./2a-variations";
2023-07-02 15:49:36 -04:00
import { transform2Post } from "./2b-post";
2023-07-01 00:38:15 -04:00
export class FlameFinal extends Flame {
didLog: boolean = false;
2023-07-01 00:38:15 -04:00
constructor(
transforms: [number, Transform][],
public readonly final: Transform
) {
super(transforms);
}
override step(): void {
2023-07-02 15:30:56 -04:00
super.step();
[this.x, this.y] = this.final.apply(this.x, this.y);
2023-07-01 00:38:15 -04:00
}
override current() {
if (!this.didLog) {
this.didLog = true;
console.trace(`Getting final xform to plot`);
}
// NOTE: The final transform does not modify the iterator point
// return this.final.apply(this.x, this.y);
return [this.x, this.y];
}
2023-07-01 00:38:15 -04:00
}
2023-07-02 15:49:36 -04:00
export const transformFinal = new Transform(
{
a: 2,
b: 0,
c: 0,
d: 0,
e: 2,
f: 0,
},
[[1, julia]]
);
2023-07-01 00:38:15 -04:00
export const flameFinal = new FlameFinal(
[
[transform1Weight, transform1],
[transform2Weight, transform2Post],
[transform3Weight, transform3],
],
transformFinal
);
2023-07-01 00:38:15 -04:00
export function renderFinal(image: ImageData) {
render(flameFinal, 1, image);
2023-07-01 00:38:15 -04:00
}