Skip to content

Commit 04279a4

Browse files
feat(evals): add skia category with 20 react-native-skia evals (#377)
* feat(evals): add skia category with 20 react-native-skia evals * feat: default opencode port value, do not run opencode server if already up, deintegrate provider-specific code * chore: changes after CR * feat: add Skia evals starter templates * feat: consistently require the canvas to be present * chore: add missing inputs key * fix: remove obsolete & inconsistent pieces * feat: add evals for: Group layer + Paint + Blur, SweepGradient, ParagraphBuilder * feat: eval for imperative canvas APIs * refactor: consistently type port as non-nullable * chore: update Skia README * chore: add missing COLORS to Skia eval 21 * chore: unify declarations in Skia eval 22 * feat: add Skottie eval * fix: resolve conflicts after merge * fix: resolve typing issues --------- Co-authored-by: artus9033 <artus9033@gmail.com>
1 parent 772fea7 commit 04279a4

106 files changed

Lines changed: 1927 additions & 42 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Platform } from 'react-native'
2+
3+
const FONT_SIZE = 18
4+
5+
const fontStyle = {
6+
fontFamily: Platform.select({ ios: 'Helvetica', default: 'serif' }),
7+
fontSize: FONT_SIZE,
8+
fontWeight: 'bold',
9+
} as const
10+
11+
export default function App() {
12+
return <></>
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement a full-screen Skia canvas with a solid background color using Fill. Display the current canvas width and height as centered text inside the canvas. Use useCanvasSize to read the canvas dimensions on the JS thread and position the text accordingly.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Platform } from 'react-native'
2+
import { Canvas, Fill, Text, matchFont, useCanvasSize } from '@shopify/react-native-skia'
3+
4+
const FONT_SIZE = 18
5+
6+
const fontStyle = {
7+
fontFamily: Platform.select({ ios: 'Helvetica', default: 'serif' }),
8+
fontSize: FONT_SIZE,
9+
fontWeight: 'bold',
10+
} as const
11+
12+
const font = matchFont(fontStyle)
13+
14+
function CanvasContent() {
15+
const { width, height } = useCanvasSize()
16+
17+
const label = `${Math.round(width)} × ${Math.round(height)}`
18+
const textX = width / 2 - (font?.getTextWidth(label) ?? 0) / 2
19+
const textY = height / 2 + FONT_SIZE / 2
20+
21+
return (
22+
<>
23+
<Fill color='#1e293b' />
24+
<Text x={textX} y={textY} text={label} font={font} color='#f8fafc' />
25+
</>
26+
)
27+
}
28+
29+
export default function App() {
30+
return (
31+
<Canvas style={{ flex: 1 }}>
32+
<CanvasContent />
33+
</Canvas>
34+
)
35+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 1
2+
inputs:
3+
files:
4+
- app/App.tsx
5+
requirements:
6+
- id: uses-canvas-component
7+
description: Must render all drawing content inside a Canvas component from @shopify/react-native-skia.
8+
- id: uses-fill-for-background
9+
description: Must use the Fill component from @shopify/react-native-skia to paint the canvas background color.
10+
- id: uses-canvas-size-hook
11+
description: Must use useCanvasSize from @shopify/react-native-skia to read canvas dimensions on the JS thread.
12+
- id: displays-dimensions-as-text
13+
description: Must render the canvas width and height as visible text inside the canvas using the Text component from @shopify/react-native-skia.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Canvas, Fill } from '@shopify/react-native-skia'
2+
3+
const PADDING = 24
4+
const SHAPE_SIZE = 80
5+
6+
export default function App() {
7+
return (
8+
<Canvas style={{ flex: 1 }}>
9+
<Fill color="#f1f5f9" />
10+
</Canvas>
11+
)
12+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Draw a composition of basic shapes on a Skia canvas: a filled rectangle, a filled circle, a rounded rectangle, and a straight line. Give each shape a distinct color and arrange them so they are all visible without overlap.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {
2+
Canvas,
3+
Circle,
4+
Fill,
5+
Line,
6+
Rect,
7+
RoundedRect,
8+
vec,
9+
} from '@shopify/react-native-skia'
10+
11+
const PADDING = 24
12+
const SHAPE_SIZE = 80
13+
14+
export default function App() {
15+
return (
16+
<Canvas style={{ flex: 1 }}>
17+
<Fill color="#f1f5f9" />
18+
19+
<Rect
20+
x={PADDING}
21+
y={PADDING}
22+
width={SHAPE_SIZE}
23+
height={SHAPE_SIZE}
24+
color="#3b82f6"
25+
/>
26+
27+
<Circle
28+
cx={PADDING + SHAPE_SIZE + 40 + SHAPE_SIZE / 2}
29+
cy={PADDING + SHAPE_SIZE / 2}
30+
r={SHAPE_SIZE / 2}
31+
color="#ef4444"
32+
/>
33+
34+
<RoundedRect
35+
x={PADDING}
36+
y={PADDING + SHAPE_SIZE + 24}
37+
width={SHAPE_SIZE}
38+
height={SHAPE_SIZE}
39+
r={16}
40+
color="#22c55e"
41+
/>
42+
43+
<Line
44+
p1={vec(PADDING, PADDING + (SHAPE_SIZE + 24) * 2 + 40)}
45+
p2={vec(
46+
PADDING + SHAPE_SIZE * 2 + 40,
47+
PADDING + (SHAPE_SIZE + 24) * 2 + 40
48+
)}
49+
color="#f59e0b"
50+
strokeWidth={4}
51+
/>
52+
</Canvas>
53+
)
54+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 1
2+
inputs:
3+
files:
4+
- app/App.tsx
5+
requirements:
6+
- id: uses-canvas-component
7+
description: Must render all drawing content inside a Canvas component from @shopify/react-native-skia.
8+
weight: 0.1
9+
- id: uses-rect-component
10+
description: Must render a Rect component from @shopify/react-native-skia.
11+
- id: uses-circle-component
12+
description: Must render a Circle component from @shopify/react-native-skia.
13+
- id: uses-rounded-rect-component
14+
description: Must render a RoundedRect or equivalent rounded rectangle component from @shopify/react-native-skia.
15+
- id: uses-line-component
16+
description: Must render a Line component from @shopify/react-native-skia.
17+
- id: shapes-have-distinct-colors
18+
description: Each shape must use a visually distinct color.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Canvas, Fill } from '@shopify/react-native-skia'
2+
3+
const STROKE_WIDTH = 4
4+
5+
export default function App() {
6+
return (
7+
<Canvas style={{ flex: 1 }}>
8+
<Fill color="#0f172a" />
9+
</Canvas>
10+
)
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Draw a custom Bezier curve path on a Skia canvas. Build the path imperatively using Skia.Path.Make() with moveTo and cubicTo commands, and render it as a stroked line with a visible stroke width and color.

0 commit comments

Comments
 (0)