@meursyphus/flitter 2.0.0-alpha.6 → 2.0.0-alpha.7

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.
package/index.cjs CHANGED
@@ -123,7 +123,13 @@ var SceneBuilder = class {
123
123
  }
124
124
  render(ctx) {
125
125
  for (const { x, y, picture } of __privateGet(this, _pictures)) {
126
- ctx.drawImage(picture.toImage(), x, y);
126
+ ctx.drawImage(
127
+ picture.toImage(),
128
+ x,
129
+ y,
130
+ picture.size.width,
131
+ picture.size.height
132
+ );
127
133
  }
128
134
  }
129
135
  addPicture(props) {
@@ -140,6 +146,12 @@ var Picture = class {
140
146
  toImage() {
141
147
  return __privateGet(this, _source);
142
148
  }
149
+ get size() {
150
+ return {
151
+ width: __privateGet(this, _source).width / window.devicePixelRatio,
152
+ height: __privateGet(this, _source).height / window.devicePixelRatio
153
+ };
154
+ }
143
155
  };
144
156
  _source = new WeakMap();
145
157
  var _source2;
@@ -151,8 +163,9 @@ var PictureRecorder = class {
151
163
  constructor(paintBounds) {
152
164
  __privateAdd(this, _source2, void 0);
153
165
  __privateSet(this, _source2, document.createElement("canvas"));
154
- __privateGet(this, _source2).width = paintBounds.width;
155
- __privateGet(this, _source2).height = paintBounds.height;
166
+ const dpr = window.devicePixelRatio;
167
+ __privateGet(this, _source2).width = paintBounds.width * dpr;
168
+ __privateGet(this, _source2).height = paintBounds.height * dpr;
156
169
  }
157
170
  /**
158
171
  * @implements: This function is still incomplete. So It needs paintSize temporarily. Once completed, it will intercept the CanvasRenderingContext2D API
@@ -161,6 +174,7 @@ var PictureRecorder = class {
161
174
  */
162
175
  createCanvasContext() {
163
176
  const ctx = __privateGet(this, _source2).getContext("2d");
177
+ ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
164
178
  return ctx;
165
179
  }
166
180
  endRecording() {
package/index.d.cts CHANGED
@@ -3540,6 +3540,10 @@ declare class Picture {
3540
3540
  #private;
3541
3541
  constructor(source: HTMLCanvasElement);
3542
3542
  toImage(): CanvasImageSource;
3543
+ get size(): {
3544
+ width: number;
3545
+ height: number;
3546
+ };
3543
3547
  }
3544
3548
 
3545
3549
  declare class CanvasPaintingContext {
package/index.d.ts CHANGED
@@ -3540,6 +3540,10 @@ declare class Picture {
3540
3540
  #private;
3541
3541
  constructor(source: HTMLCanvasElement);
3542
3542
  toImage(): CanvasImageSource;
3543
+ get size(): {
3544
+ width: number;
3545
+ height: number;
3546
+ };
3543
3547
  }
3544
3548
 
3545
3549
  declare class CanvasPaintingContext {
package/index.global.js CHANGED
@@ -304,7 +304,13 @@
304
304
  }
305
305
  render(ctx) {
306
306
  for (const { x, y, picture } of __privateGet(this, _pictures)) {
307
- ctx.drawImage(picture.toImage(), x, y);
307
+ ctx.drawImage(
308
+ picture.toImage(),
309
+ x,
310
+ y,
311
+ picture.size.width,
312
+ picture.size.height
313
+ );
308
314
  }
309
315
  }
310
316
  addPicture(props) {
@@ -321,6 +327,12 @@
321
327
  toImage() {
322
328
  return __privateGet(this, _source);
323
329
  }
330
+ get size() {
331
+ return {
332
+ width: __privateGet(this, _source).width / window.devicePixelRatio,
333
+ height: __privateGet(this, _source).height / window.devicePixelRatio
334
+ };
335
+ }
324
336
  };
325
337
  _source = new WeakMap();
326
338
  var _source2;
@@ -332,8 +344,9 @@
332
344
  constructor(paintBounds) {
333
345
  __privateAdd(this, _source2, void 0);
334
346
  __privateSet(this, _source2, document.createElement("canvas"));
335
- __privateGet(this, _source2).width = paintBounds.width;
336
- __privateGet(this, _source2).height = paintBounds.height;
347
+ const dpr = window.devicePixelRatio;
348
+ __privateGet(this, _source2).width = paintBounds.width * dpr;
349
+ __privateGet(this, _source2).height = paintBounds.height * dpr;
337
350
  }
338
351
  /**
339
352
  * @implements: This function is still incomplete. So It needs paintSize temporarily. Once completed, it will intercept the CanvasRenderingContext2D API
@@ -342,6 +355,7 @@
342
355
  */
343
356
  createCanvasContext() {
344
357
  const ctx = __privateGet(this, _source2).getContext("2d");
358
+ ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
345
359
  return ctx;
346
360
  }
347
361
  endRecording() {
package/index.js CHANGED
@@ -123,7 +123,13 @@ var SceneBuilder = class {
123
123
  }
124
124
  render(ctx) {
125
125
  for (const { x, y, picture } of __privateGet(this, _pictures)) {
126
- ctx.drawImage(picture.toImage(), x, y);
126
+ ctx.drawImage(
127
+ picture.toImage(),
128
+ x,
129
+ y,
130
+ picture.size.width,
131
+ picture.size.height
132
+ );
127
133
  }
128
134
  }
129
135
  addPicture(props) {
@@ -140,6 +146,12 @@ var Picture = class {
140
146
  toImage() {
141
147
  return __privateGet(this, _source);
142
148
  }
149
+ get size() {
150
+ return {
151
+ width: __privateGet(this, _source).width / window.devicePixelRatio,
152
+ height: __privateGet(this, _source).height / window.devicePixelRatio
153
+ };
154
+ }
143
155
  };
144
156
  _source = new WeakMap();
145
157
  var _source2;
@@ -151,8 +163,9 @@ var PictureRecorder = class {
151
163
  constructor(paintBounds) {
152
164
  __privateAdd(this, _source2, void 0);
153
165
  __privateSet(this, _source2, document.createElement("canvas"));
154
- __privateGet(this, _source2).width = paintBounds.width;
155
- __privateGet(this, _source2).height = paintBounds.height;
166
+ const dpr = window.devicePixelRatio;
167
+ __privateGet(this, _source2).width = paintBounds.width * dpr;
168
+ __privateGet(this, _source2).height = paintBounds.height * dpr;
156
169
  }
157
170
  /**
158
171
  * @implements: This function is still incomplete. So It needs paintSize temporarily. Once completed, it will intercept the CanvasRenderingContext2D API
@@ -161,6 +174,7 @@ var PictureRecorder = class {
161
174
  */
162
175
  createCanvasContext() {
163
176
  const ctx = __privateGet(this, _source2).getContext("2d");
177
+ ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
164
178
  return ctx;
165
179
  }
166
180
  endRecording() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meursyphus/flitter",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.7",
4
4
  "description": "A declarative, widget-based library built on SVG for simplifying data visualization with a Flutter-like syntax.",
5
5
  "keywords": [
6
6
  "flitter",