Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Dev canvas image #455

Closed

Conversation

yueyuzhao
Copy link
Contributor

@yueyuzhao yueyuzhao commented Jun 20, 2021

Resolves

Proposed Changes

This PR resolves 2 things:

  1. display project sprites and backgrounds with canvas
  2. replace SVG icons with PNG in Paint page

Reason for Changes

On some old Android devices, SVG causes some wired display issue and WebView can't handle SVG well.

We should avoid using SVG image files directly to increase app performance.

Test Coverage

  • Projects show well on Android
  • Painter works well on Android
  • Projects show well on iOS
  • Painter works well on iOS

@yueyuzhao
Copy link
Contributor Author

This PR may also fix #445 and #448 , but more tests should be done.

@yueyuzhao
Copy link
Contributor Author

yueyuzhao commented Jun 20, 2021

Note that on some hi-res devices, the icons may not be as smooth as the SVG types, but we can improve this by increasing the PNG image size.

Edit:
Also note that it also requires the official/PBS and other editions to follow up those changes.

@yueyuzhao yueyuzhao marked this pull request as ready for review June 20, 2021 23:28
Copy link
Contributor

@chrisgarrity chrisgarrity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yueyuzhao after discussing this with others on the team, I don't think we want to degrade the experience for all users in order to support these old devices this way. It would be better to implement additional flavor dimensions for Android based on the API level as shown in this example: https://developer.android.com/studio/build/build-variants#flavor-dimensions.

} else {
var self = this;
newImage(null, url, null, function (img) {
self.bkg.originalImg = img.cloneNode(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to have additional comments explaining why it needs to be a canvas.

var canvas = newCanvas(sprite.div, 0, 0, img.naturalWidth, img.naturalHeight);
var context = canvas.getContext('2d');
context.drawImage(img, 0, 0);
sprite.img = canvas;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like setBackgroundImage it would be helpful to have an explanation for why it needs to be using canvas.

@chrisgarrity chrisgarrity marked this pull request as draft July 30, 2021 12:56
@yueyuzhao
Copy link
Contributor Author

I'll split this PR to several small PRs that will fix specific issue separately.

@yueyuzhao yueyuzhao closed this Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Painter graphic display error
2 participants