Skip to content

Commit

Permalink
screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
pandrr committed Feb 4, 2025
1 parent f1749f9 commit dac8a5b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/core/cg/cg_state.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Events } from "cables-shared-client";
import { CgCanvas } from "./cg_canvas.js";
import { MatrixStack } from "./cg_matrixstack.js";
import Patch from "../core_patch.js";

class CGState extends Events
{

/**
* Description
* @param {CABLES.Patch} _patch
* @param {Patch} _patch
*/
constructor(_patch)
{
Expand Down Expand Up @@ -392,7 +393,6 @@ class CGState extends Events
}

const d = new Date();

const dateStr = "".concat(String(d.getFullYear()) + String(d.getMonth() + 1) + String(d.getDate()), "_").concat(padLeft(d.getHours(), 2)).concat(padLeft(d.getMinutes(), 2)).concat(padLeft(d.getSeconds(), 2));

if (!filename) filename = "cables_" + dateStr + ".png";
Expand Down
16 changes: 6 additions & 10 deletions src/core/cgp/cgp_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,19 +520,15 @@ class WebGpuContext extends CGState
*/
screenShot(cb, doScreenshotClearAlpha, mimeType, quality)
{

setTimeout(() =>
if (this.canvas && this.canvas.toBlob)
{
if (this.canvas && this.canvas.toBlob)
this.canvas.toBlob((blob) =>
{
this.canvas.toBlob((blob) =>
{
if (cb) cb(blob);
else this._log.log("no screenshot callback...");
}, mimeType, quality);
}
if (cb) cb(blob);
else this._log.log("no screenshot callback...");
}, mimeType, quality);
}

}, 400); // todo remove timeout, implement renderOneFrame as in cgl
}

}
Expand Down
1 change: 1 addition & 0 deletions src/core/core_patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class Patch extends Events
return this._renderOneFrame;
}

/** @deprecated */
renderOneFrame()
{
this._paused = true;
Expand Down

0 comments on commit dac8a5b

Please sign in to comment.