Closed samreid closed 3 weeks ago
Here is a proposal that addresses the recommendations above. I noted that it yielded a slightly different boat and bottle when I ran it. I wonder if they have changed or maybe it is platform dependent.
I'd like to check in with @zepumph before taking this idea to production.
Also, do we want the PNGs upside down? (they are currently upside down). If not, we can open a side issue for that.
@zepumph and I discussed. We agreed:
getFallbackIcon
. We will use the PNGs as the fallback.In the preceding commit I manually flipped the images via Photoshop => Image => Image Rotation => Flip Canvas Vertical.
Next I flipped the camera upside down for creating the images like this:
The boat comes out upside up, but unfortunately it is facing right.
@zepumph is it OK to do Photoshop => Image => Image Rotation => Flip Canvas Vertical as needed, or should we flip/scale the canvas?
This batch of code flips the image correctly, but returns the new canvas. I think we can just reuse the same canvas:
// Create a temp canvas to store our data (because we need to clear the other box after rotation.
const tempCanvas = document.createElement( 'canvas' );
const tempCtx = tempCanvas.getContext( '2d' )!;
tempCanvas.width = canvas.width;
tempCanvas.height = canvas.height;
tempCtx.translate( canvas.width, canvas.height );
tempCtx.scale( 1, -1 );
tempCtx.drawImage( canvas, canvas.width * -1, 0 );
return tempCanvas;
I believe that I have made the canvas right side up before using (either printing or as the SCENERY/Image). I prefer this to a manual step, and I was glad for the challenge of supporting this via canvas (a tech I'm not too used to).
Please review my commit. Can you take it from here? Do all images need to be regenerated?
I talked things through with @samreid, and we were happy with the above improvements. Thanks for all your work here @samreid. Closing. We can pick things up over in https://github.com/phetsims/buoyancy/issues/48
Discovered in #48 it would be good to streamline the code that generates images. There is a lot of duplicated code in the existing implementation. I recommend the following:
?generateIconImages
will be changed so that it only checks that the rendering matches the png. PNG is still returned.getFallbackIcon