Skip to content

Commit

Permalink
Add method to save multiple images at one time.
Browse files Browse the repository at this point in the history
  • Loading branch information
azurepolarbear committed Dec 29, 2024
1 parent e0a9178 commit 048de36
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 24 deletions.
106 changes: 83 additions & 23 deletions src/main/wave-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import P5Lib from 'p5';

import {
ASPECT_RATIOS,
ASPECT_RATIOS, AspectRatio,
CanvasContext,
CanvasScreen,
Color,
Expand Down Expand Up @@ -59,6 +59,30 @@ export abstract class WaveScreen extends CanvasScreen {
this.#background = new Color(0, 0, 0);
}

public static get POINT_DENSITY_SELECTOR(): CategorySelector<PointDensity> {
return WaveScreen.#POINT_DENSITY_SELECTOR;
}

public static get POINT_SIZE_SELECTOR(): CategorySelector<PointSize> {
return WaveScreen.#POINT_SIZE_SELECTOR;
}

public get sameWaveAmplitude(): boolean {
return true;
}

public get sameWaveDeltaTheta(): boolean {
return true;
}

public get sameWaveInitialTheta(): boolean {
return true;
}

public get sameWaveFrequency(): boolean {
return true;
}

public override activate(): void {
super.activate();
P5Context.p5.background(this.#background.color);
Expand Down Expand Up @@ -89,6 +113,8 @@ export abstract class WaveScreen extends CanvasScreen {
ScreenHandler.currentScreen = 'vertical waves';
} else if (p5.key === 'd') {
ScreenHandler.currentScreen = 'wave testing';
} else if (p5.key === 'z') {
this.saveSocialMediaSet(1_000).then((): void => console.log('Social media set saved.'));
}

p5.background(this.#background.color);
Expand All @@ -98,27 +124,61 @@ export abstract class WaveScreen extends CanvasScreen {
console.log('mousePressed() placeholder');
}

public get sameWaveAmplitude(): boolean {
return true;
}

public get sameWaveDeltaTheta(): boolean {
return true;
}

public get sameWaveInitialTheta(): boolean {
return true;
}

public get sameWaveFrequency(): boolean {
return true;
}

public static get POINT_DENSITY_SELECTOR(): CategorySelector<PointDensity> {
return WaveScreen.#POINT_DENSITY_SELECTOR;
}

public static get POINT_SIZE_SELECTOR(): CategorySelector<PointSize> {
return WaveScreen.#POINT_SIZE_SELECTOR;
public async saveSocialMediaSet(timeout: number): Promise<void> {
const p5: P5Lib = P5Context.p5;
let ratio: AspectRatio = ASPECT_RATIOS.SQUARE;
let count: number = 1;
CanvasContext.updateAspectRatio(ratio);
await new Promise<void>(f => {
setTimeout(f, timeout);
});
p5.save(`${this.NAME}_0${count}_${ratio.NAME}.png`);
await new Promise<void>(f => {
setTimeout(f, timeout);
});

ratio = ASPECT_RATIOS.PINTEREST_PIN;
count++;
CanvasContext.updateAspectRatio(ratio);
await new Promise<void>(f => {
setTimeout(f, timeout);
});
p5.save(`${this.NAME}_0${count}_${ratio.NAME}.png`);
await new Promise<void>(f => {
setTimeout(f, timeout);
});

ratio = ASPECT_RATIOS.TIKTOK_PHOTO;
count++;
CanvasContext.updateAspectRatio(ratio);
await new Promise<void>(f => {
setTimeout(f, timeout);
});
p5.save(`${this.NAME}_0${count}_${ratio.NAME}.png`);
await new Promise<void>(f => {
setTimeout(f, timeout);
});

ratio = ASPECT_RATIOS.SOCIAL_VIDEO;
count++;
CanvasContext.updateAspectRatio(ratio);
await new Promise<void>(f => {
setTimeout(f, timeout);
});
p5.save(`${this.NAME}_0${count}_${ratio.NAME}.png`);
await new Promise<void>(f => {
setTimeout(f, timeout);
});

ratio = ASPECT_RATIOS.WIDESCREEN;
count++;
CanvasContext.updateAspectRatio(ratio);
await new Promise<void>(f => {
setTimeout(f, timeout);
});
p5.save(`${this.NAME}_0${count}_${ratio.NAME}.png`);
await new Promise<void>(f => {
setTimeout(f, timeout);
});
}
}
1 change: 0 additions & 1 deletion src/main/wave/wave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export class Wave implements CanvasRedrawListener {
waveRatioEnd = waveRatioStart + waveRatioSize;

if (1 - waveRatioEnd < minPointSize) {
console.log('end end end');
waveRatioEnd = 1;
}

Expand Down

0 comments on commit 048de36

Please sign in to comment.