drawnui-react 0.1.0-preview.19 → 0.1.0-preview.20

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.
@@ -46,6 +46,10 @@ export declare class CachedObject {
46
46
  PlaybackDistorted: boolean;
47
47
  /** A picture holding image blits, whose sampling was fixed when it was recorded (C# CachedObject.HasImageBlits). */
48
48
  HasImageBlits: boolean;
49
+ /** C# PaintRenderObject: the blit paint is antialiased (else a turned bitmap keeps stair steps along its own border), dithered when distorted. */
50
+ private static blitPaint?;
51
+ private static blitPaintDithered?;
52
+ private static BlitPaint;
49
53
  /** Replays the cache with its top-left moved to (left, top); `smooth` = an image drawn distorted (linear + mipmaps). */
50
54
  Draw(canvas: SkCanvas, left: number, top: number, smooth?: boolean): void;
51
55
  Dispose(): void;
@@ -28,15 +28,23 @@ export class CachedObject {
28
28
  PlaybackDistorted = false;
29
29
  /** A picture holding image blits, whose sampling was fixed when it was recorded (C# CachedObject.HasImageBlits). */
30
30
  HasImageBlits = false;
31
+ /** C# PaintRenderObject: the blit paint is antialiased (else a turned bitmap keeps stair steps along its own border), dithered when distorted. */
32
+ static blitPaint;
33
+ static blitPaintDithered;
34
+ static BlitPaint(dither) {
35
+ const CK = Super.CK;
36
+ const make = () => { const p = new CK.Paint(); p.setAntiAlias(true); p.setDither(dither); return p; };
37
+ return dither ? (CachedObject.blitPaintDithered ??= make()) : (CachedObject.blitPaint ??= make());
38
+ }
31
39
  /** Replays the cache with its top-left moved to (left, top); `smooth` = an image drawn distorted (linear + mipmaps). */
32
40
  Draw(canvas, left, top, smooth = false) {
33
41
  const CK = Super.CK;
34
42
  if (this.Image) {
35
43
  // nearest keeps a bitmap blitted 1:1 sharp; once scaled, turned or projected it needs smooth sampling (C# 1e4610f6)
36
44
  if (smooth)
37
- canvas.drawImageOptions(this.Image, left, top, CK.FilterMode.Linear, CK.MipmapMode.Linear, null);
45
+ canvas.drawImageOptions(this.Image, left, top, CK.FilterMode.Linear, CK.MipmapMode.Linear, CachedObject.BlitPaint(true));
38
46
  else
39
- canvas.drawImageOptions(this.Image, left, top, CK.FilterMode.Nearest, CK.MipmapMode.None, null);
47
+ canvas.drawImageOptions(this.Image, left, top, CK.FilterMode.Nearest, CK.MipmapMode.None, CachedObject.BlitPaint(false));
40
48
  }
41
49
  else if (this.Picture) {
42
50
  const saved = canvas.save();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drawnui-react",
3
- "version": "0.1.0-preview.19",
3
+ "version": "0.1.0-preview.20",
4
4
  "description": "DrawnUi for React: the DrawnUi (.NET) drawn-UI engine in TypeScript on CanvasKit (Skia WASM). Same controls, same PascalCase API as DrawnUi.Net.",
5
5
  "license": "MIT",
6
6
  "author": "Nick Kovalsky (AppoMobi)",