add more functions

This commit is contained in:
2023-08-03 00:25:40 +02:00
parent 405af94d16
commit 9a00b6bf2a
3 changed files with 12 additions and 5 deletions

View File

@ -36,6 +36,11 @@ To evaluate code, press `Ctrl+Enter` (no visible animation). This is true for ev
# TODO
## API
- [ ] Give information about its context of execution to every script
- knowing which internal iterator to use for each script would be nice
## Scheduler
- [ ] Stable / robust clock and script/event scheduler.

View File

@ -93,8 +93,6 @@ export class UserAPI {
return this.app._mouseY
}
// =============================================================
// Utility functions
// =============================================================
@ -363,9 +361,14 @@ export class UserAPI {
return final_pulses.some(p => p == true)
}
every(...n: number[]): boolean {
return n.some(n => this.i % n === 0)
stop(): void {
this.app.clock.pause()
this.app.setButtonHighlighting("pause", true);
}
silence = this.stop
hush = this.stop
prob(p: number): boolean { return Math.random() * 100 < p }
mod(...pulse: number[]): boolean { return pulse.some(p => this.app.clock.time_position.pulse % p === 0) }
modbar(...bar: number[]): boolean { return bar.some(b => this.app.clock.time_position.bar % b === 0) }

View File

@ -45,7 +45,6 @@ export class Editor {
clock: Clock;
manualPlay: boolean = false;
// Mouse position
public _mouseX: number = 0;
public _mouseY: number = 0;