@novely/solid-renderer 0.35.0 → 0.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.jsx +14 -14
  2. package/package.json +1 -1
package/dist/index.jsx CHANGED
@@ -5118,8 +5118,8 @@ var canvasDrawImages = async (canvas = createCanvas(), ctx = getContext(canvas),
5118
5118
  const sizesSorted = images.slice().sort((a, b) => b.width - a.width);
5119
5119
  const sizes = sizesSorted[0];
5120
5120
  const scaleBy = canvas.dataset.scaleBy ? Number(canvas.dataset.scaleBy) : 1;
5121
- canvas.width = Math.min(sizes.naturalWidth * scaleBy * 2, sizes.naturalWidth);
5122
- canvas.height = Math.min(sizes.naturalHeight * scaleBy * 2, sizes.naturalHeight);
5121
+ canvas.width = Math.min(sizes.naturalWidth * scaleBy * 2, sizes.naturalWidth) * devicePixelRatio;
5122
+ canvas.height = Math.min(sizes.naturalHeight * scaleBy * 2, sizes.naturalHeight) * devicePixelRatio;
5123
5123
  canvas.dataset.resized = "true";
5124
5124
  }
5125
5125
  for (const image of images) {
@@ -6296,12 +6296,11 @@ var Game = (props) => {
6296
6296
  const {
6297
6297
  clientWidth,
6298
6298
  clientHeight
6299
- } = props.context.root;
6300
- const w = Math.ceil(Math.min(clientWidth, img.width));
6301
- const h = Math.ceil(Math.min(clientHeight, img.height));
6302
- canvas.width = w;
6303
- canvas.height = h;
6304
- ctx.drawImage(img, 0, 0, w, h);
6299
+ } = context.root;
6300
+ const maxFactor = 1 / Math.ceil(Math.max(img.width / clientWidth, img.height / clientHeight));
6301
+ canvas.width = Math.min(img.width * maxFactor, img.width) * devicePixelRatio;
6302
+ canvas.height = Math.min(img.height * maxFactor, img.height) * devicePixelRatio;
6303
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
6305
6304
  }
6306
6305
  }
6307
6306
  }), _el$2);
@@ -7228,12 +7227,6 @@ var createSolidRenderer = ({
7228
7227
  if (shouldRender && stored) {
7229
7228
  canvasContext.clearRect(0, 0, canvas.width, canvas.height);
7230
7229
  canvas.dataset.resized = "false";
7231
- const sizes = characterAssetSizes[character];
7232
- if (sizes) {
7233
- canvas.width = sizes.width;
7234
- canvas.height = sizes.height;
7235
- canvas.dataset.resized = "true";
7236
- }
7237
7230
  if (root() !== context.root) {
7238
7231
  const {
7239
7232
  clientWidth: mainClientWidth,
@@ -7250,6 +7243,13 @@ var createSolidRenderer = ({
7250
7243
  } else {
7251
7244
  canvas.dataset.scalyBy = "1";
7252
7245
  }
7246
+ const sizes = characterAssetSizes[character];
7247
+ if (sizes) {
7248
+ const scaleBy = canvas.dataset.scaleBy ? Number(canvas.dataset.scaleBy) : 1;
7249
+ canvas.width = Math.min(sizes.width * scaleBy * 2, sizes.width) * devicePixelRatio;
7250
+ canvas.height = Math.min(sizes.height * scaleBy * 2, sizes.height) * devicePixelRatio;
7251
+ canvas.dataset.resized = "true";
7252
+ }
7253
7253
  canvasDrawImages(canvas, canvasContext, stored);
7254
7254
  }
7255
7255
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.35.0",
3
+ "version": "0.35.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"