continue with small optimizations
This commit is contained in:
@ -93,26 +93,29 @@ export const blinkScript = (
|
|||||||
(app.interface.feedback as HTMLCanvasElement).width,
|
(app.interface.feedback as HTMLCanvasElement).width,
|
||||||
(app.interface.feedback as HTMLCanvasElement).height
|
(app.interface.feedback as HTMLCanvasElement).height
|
||||||
);
|
);
|
||||||
drawEmptyBlinkers(app);
|
|
||||||
}, blinkDuration);
|
}, blinkDuration);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a series of 9 white circles.
|
* Manages animation updates using requestAnimationFrame.
|
||||||
* @param app - The Editor application context.
|
* @param app - The Editor application context.
|
||||||
*/
|
*/
|
||||||
export const drawEmptyBlinkers = (app: Editor) => {
|
export const scriptBlinkers = () => {
|
||||||
for (let no = 1; no <= 9; no++) {
|
let lastFrameTime = Date.now();
|
||||||
const shiftAmount = no * 25;
|
const frameRate = 10;
|
||||||
drawCircle(
|
const minFrameDelay = 1000 / frameRate;
|
||||||
app,
|
|
||||||
50 + shiftAmount,
|
const update = () => {
|
||||||
app.interface.feedback.clientHeight - 15,
|
const now = Date.now();
|
||||||
8,
|
const timeSinceLastFrame = now - lastFrameTime;
|
||||||
"white"
|
|
||||||
);
|
if (timeSinceLastFrame >= minFrameDelay) {
|
||||||
|
lastFrameTime = now;
|
||||||
}
|
}
|
||||||
|
requestAnimationFrame(update);
|
||||||
|
};
|
||||||
|
requestAnimationFrame(update);
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface OscilloscopeConfig {
|
export interface OscilloscopeConfig {
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { Prec } from "@codemirror/state";
|
|||||||
import { indentWithTab } from "@codemirror/commands";
|
import { indentWithTab } from "@codemirror/commands";
|
||||||
import {
|
import {
|
||||||
keymap,
|
keymap,
|
||||||
ViewUpdate,
|
|
||||||
lineNumbers,
|
lineNumbers,
|
||||||
highlightSpecialChars,
|
highlightSpecialChars,
|
||||||
drawSelection,
|
drawSelection,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { OscilloscopeConfig, runOscilloscope } from "./AudioVisualisation";
|
import { OscilloscopeConfig, runOscilloscope, scriptBlinkers } from "./AudioVisualisation";
|
||||||
import { EditorState, Compartment } from "@codemirror/state";
|
import { EditorState, Compartment } from "@codemirror/state";
|
||||||
import { javascript } from "@codemirror/lang-javascript";
|
import { javascript } from "@codemirror/lang-javascript";
|
||||||
import { markdown } from "@codemirror/lang-markdown";
|
import { markdown } from "@codemirror/lang-markdown";
|
||||||
@ -27,7 +27,6 @@ import showdown from "showdown";
|
|||||||
import { makeStringExtensions } from "./extensions/StringExtensions";
|
import { makeStringExtensions } from "./extensions/StringExtensions";
|
||||||
import { installInterfaceLogic } from "./InterfaceLogic";
|
import { installInterfaceLogic } from "./InterfaceLogic";
|
||||||
import { installWindowBehaviors } from "./WindowBehavior";
|
import { installWindowBehaviors } from "./WindowBehavior";
|
||||||
import { drawEmptyBlinkers } from "./AudioVisualisation";
|
|
||||||
import { makeNumberExtensions } from "./extensions/NumberExtensions";
|
import { makeNumberExtensions } from "./extensions/NumberExtensions";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { registerSW } from "virtual:pwa-register";
|
import { registerSW } from "virtual:pwa-register";
|
||||||
@ -170,7 +169,7 @@ export class Editor {
|
|||||||
registerFillKeys(this);
|
registerFillKeys(this);
|
||||||
registerOnKeyDown(this);
|
registerOnKeyDown(this);
|
||||||
installInterfaceLogic(this);
|
installInterfaceLogic(this);
|
||||||
drawEmptyBlinkers(this);
|
scriptBlinkers();
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
// Building CodeMirror Editor
|
// Building CodeMirror Editor
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const vitePWAconfiguration = {
|
|||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
cleanupOutdatedCaches: true,
|
cleanupOutdatedCaches: true,
|
||||||
globPatterns: [
|
globPatterns: [
|
||||||
"**/*.{js,css,html,gif,png,json,woff,json,ogg,wav,mp3,ico,png,svg}",
|
"**/*.{js,css,html,gif,png,json,woff,woff2,json,ogg,wav,mp3,ico,png,svg}",
|
||||||
],
|
],
|
||||||
// Thanks Froos :)
|
// Thanks Froos :)
|
||||||
runtimeCaching: [
|
runtimeCaching: [
|
||||||
|
|||||||
Reference in New Issue
Block a user