Skip to content

Commit

Permalink
🏞️ offscreen example (#2765)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Nov 23, 2024
1 parent f4db5f5 commit 1352eca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/paper/src/Examples/API/Data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Image,
Skia,
} from "@shopify/react-native-skia";
import { PixelRatio } from "react-native";

const pixels = new Uint8Array(256 * 256 * 4);
pixels.fill(255);
Expand All @@ -27,12 +28,16 @@ const img = Skia.Image.MakeImage(
256 * 4
)!;

const surface = Skia.Surface.MakeOffscreen(256, 256)!;
const pd = PixelRatio.get();
const surface = Skia.Surface.MakeOffscreen(256 * pd, 256 * pd)!;
const canvas = surface.getCanvas();
canvas.save();
canvas.scale(pd, pd);
canvas.drawColor(Skia.Color("cyan"));
const paint = Skia.Paint();
paint.setColor(Skia.Color("magenta"));
canvas.drawCircle(128, 128, 128, paint);
canvas.restore();
const img1 = surface.makeImageSnapshot().makeNonTextureImage();

export const Data = () => {
Expand Down

0 comments on commit 1352eca

Please sign in to comment.