diff --git a/1224/react-native-canvas.md b/1224/react-native-canvas.md index 31eb0477982fe5a40512708e0c2f0be59f67f5c2..686144e379ede251c737a68a1c7ff688be1262bd 100644 --- a/1224/react-native-canvas.md +++ b/1224/react-native-canvas.md @@ -39,7 +39,7 @@ yarn add react-native-canvas@0.1.39 ```tsx import React, { useRef, useEffect } from 'react'; import { View, StyleSheet, Text, ScrollView } from 'react-native'; -import Canvas, { Image as CanvasImage, CanvasRenderingContext2D } from 'react-native-canvas'; +import Canvas, { Image as CanvasImage, CanvasRenderingContext2D, Path2D } from 'react-native-canvas'; const CanvasDemo = () => { @@ -60,11 +60,11 @@ const CanvasDemo = () => { context.fillStyle = 'blue'; context.fillRect(10, 10, 100, 100); - //绘制圆形 - context.beginPath(); - context.arc(200, 60, 50, 0, 2 * Math.PI); + //绘制椭圆 + const ellipse = new Path2D(canvas); + ellipse.ellipse(200, 60, 50, 30, 0, 0, 2 * Math.PI); context.fillStyle = 'green'; - context.fill(); + context.fill(ellipse); //绘制线条 context.beginPath();