File tree 1 file changed +6
-1
lines changed
apps/paper/src/Examples/API
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 6
6
Image ,
7
7
Skia ,
8
8
} from "@shopify/react-native-skia" ;
9
+ import { PixelRatio } from "react-native" ;
9
10
10
11
const pixels = new Uint8Array ( 256 * 256 * 4 ) ;
11
12
pixels . fill ( 255 ) ;
@@ -27,12 +28,16 @@ const img = Skia.Image.MakeImage(
27
28
256 * 4
28
29
) ! ;
29
30
30
- const surface = Skia . Surface . MakeOffscreen ( 256 , 256 ) ! ;
31
+ const pd = PixelRatio . get ( ) ;
32
+ const surface = Skia . Surface . MakeOffscreen ( 256 * pd , 256 * pd ) ! ;
31
33
const canvas = surface . getCanvas ( ) ;
34
+ canvas . save ( ) ;
35
+ canvas . scale ( pd , pd ) ;
32
36
canvas . drawColor ( Skia . Color ( "cyan" ) ) ;
33
37
const paint = Skia . Paint ( ) ;
34
38
paint . setColor ( Skia . Color ( "magenta" ) ) ;
35
39
canvas . drawCircle ( 128 , 128 , 128 , paint ) ;
40
+ canvas . restore ( ) ;
36
41
const img1 = surface . makeImageSnapshot ( ) . makeNonTextureImage ( ) ;
37
42
38
43
export const Data = ( ) => {
You can’t perform that action at this time.
0 commit comments