Skip to content

Commit

Permalink
step2. painting overview
Browse files Browse the repository at this point in the history
  • Loading branch information
devym-37 committed Oct 10, 2023
1 parent 8f31f64 commit fa5f159
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions SkiaPractice/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SafeAreaView } from 'react-native';
import { useContextBridge, FiberProvider } from 'its-fine';
import { Canvas, Circle, Group } from '@shopify/react-native-skia';
import CanvasPractice from './src/components/Canvas';
import { Painting, PaintingInheritance } from './src/components/Painting';
import { ThemeProvider } from './src/components/Canvas/Theme/Theme';

function App(): JSX.Element {
Expand All @@ -28,6 +29,8 @@ function App(): JSX.Element {
</Group>
</Canvas> */}
<CanvasPractice />
<Painting />
<PaintingInheritance />
{/* </SafeAreaView> */}
</ThemeProvider>
</FiberProvider>
Expand Down
35 changes: 35 additions & 0 deletions SkiaPractice/src/components/Painting/Painting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Canvas, Circle, Paint, vec, Group } from '@shopify/react-native-skia';

const width = 256;
const height = 256;

const Painting = () => {
const strokeWidth = 10;
const c = vec(width / 2, height / 2);
const r = (width - strokeWidth) / 2;
return (
<Canvas style={{ width, height }}>
<Circle c={c} r={r} color="red">
<Paint color="lightblue" />
<Paint color="#adbce6" style="stroke" strokeWidth={10} />
<Paint color="#ade6d8" style="stroke" strokeWidth={strokeWidth / 2} />
</Circle>
</Canvas>
);
};

const PaintingInheritance = () => {
const r = width / 6;
return (
<Canvas style={{ width, height }}>
<Group color="lightblue">
<Circle cx={r} cy={r} r={r} />
<Group style="stroke" strokeWidth={10}>
<Circle cx={3 * r} cy={3 * r} r={r} />
</Group>
</Group>
</Canvas>
);
};

export { Painting, PaintingInheritance };
3 changes: 3 additions & 0 deletions SkiaPractice/src/components/Painting/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Painting, PaintingInheritance } from './Painting';

export { Painting, PaintingInheritance };

0 comments on commit fa5f159

Please sign in to comment.