Skip to content

Commit 1352eca

Browse files
authored
🏞️ offscreen example (#2765)
1 parent f4db5f5 commit 1352eca

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

apps/paper/src/Examples/API/Data.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Image,
77
Skia,
88
} from "@shopify/react-native-skia";
9+
import { PixelRatio } from "react-native";
910

1011
const pixels = new Uint8Array(256 * 256 * 4);
1112
pixels.fill(255);
@@ -27,12 +28,16 @@ const img = Skia.Image.MakeImage(
2728
256 * 4
2829
)!;
2930

30-
const surface = Skia.Surface.MakeOffscreen(256, 256)!;
31+
const pd = PixelRatio.get();
32+
const surface = Skia.Surface.MakeOffscreen(256 * pd, 256 * pd)!;
3133
const canvas = surface.getCanvas();
34+
canvas.save();
35+
canvas.scale(pd, pd);
3236
canvas.drawColor(Skia.Color("cyan"));
3337
const paint = Skia.Paint();
3438
paint.setColor(Skia.Color("magenta"));
3539
canvas.drawCircle(128, 128, 128, paint);
40+
canvas.restore();
3641
const img1 = surface.makeImageSnapshot().makeNonTextureImage();
3742

3843
export const Data = () => {

0 commit comments

Comments
 (0)