Snapshot toDataURL argument support (type, encoderOptions)

44 views
Skip to first unread message

Alper Akgün

unread,
Nov 30, 2017, 10:43:20 AM11/30/17
to Phaser 3 Development
Would it be possible to pass the type and encoderOptions for snapshotting in case of Canvas, and WebGL renders?
Since postRender hooks aren't implemented yet, I can't implement a common snapshotting  - as WebGL snapshots appear black.
Please ignore, or suggest otherwise if that's a superfluous request ).


// canvas
.toDataURL("image/jpeg", 0.92)

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL





// in the case of CanvasSnapshot,just adding the type and encoderOptions and passing toDataURL would be enough
var CanvasSnapshot = function (canvas, type, encoderOptions)
{
    type = type || 'image/png'
   
var src = canvas.toDataURL(type, encoderOptions);

 .....




Richard Davey

unread,
Nov 30, 2017, 9:20:18 PM11/30/17
to Alper Akgün, Phaser 3 Development
I don't see why that can't be done. Fancy submitting a PR? The same code should work for both Canvas and WebGL.

WebGL snapshots are definitely working at the moment, they don't come out black for me (at least not in Canary or Quantum) - how were you testing it?

Cheers,

Rich

Photon Storm Ltd.

Skype: richard.davey
Twitter: @photonstorm

Registered in England and Wales.
Company ID: 8036404
VAT Number: 136 4333 27

--
You received this message because you are subscribed to the Google Groups "Phaser 3 Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phaser3-dev+unsubscribe@googlegroups.com.
To post to this group, send email to phase...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/phaser3-dev/652a39db-5a2d-4f05-9f25-e060f238d4b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alper Akgün

unread,
Dec 1, 2017, 3:07:12 AM12/1/17
to Phaser 3 Development

Thanks for PR-friendliness ).  I see these 2 docs on contributing or PRs: Are there up-to-date GH PR guide for v3? For example, here it says, PRs must go to /master and not /dev and is this valid?

I misspelled: I can't implement a "custom" snapshotting in the scene's update() function as it comes black. v2 had the render() function where I could do it. Finally scenes currently don't have yet postRender hooks etc ). .
To unsubscribe from this group and stop receiving emails from it, send an email to phaser3-dev...@googlegroups.com.

Richard Davey

unread,
Jan 7, 2018, 8:27:49 AM1/7/18
to Alper Akgün, Phaser 3 Development
Just to say that I added support for this into the master branch today, so canvas and webgl snapshot now has the option to specify the type and encoding settings.

Cheers,

RIch

Photon Storm Ltd.

Skype: richard.davey
Twitter: @photonstorm

Registered in England and Wales.
Company ID: 8036404
VAT Number: 136 4333 27

To unsubscribe from this group and stop receiving emails from it, send an email to phaser3-dev+unsubscribe@googlegroups.com.

To post to this group, send email to phase...@googlegroups.com.

Alper Akgün

unread,
Jan 8, 2018, 4:45:52 AM1/8/18
to Phaser 3 Development
Awesome news. Thanks!
Reply all
Reply to author
Forward
0 new messages