From f6b946f0a1c95fa1edbfe0845f2828db40b41a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B5=A9?= Date: Mon, 1 Apr 2024 16:53:37 +0800 Subject: [PATCH] =?UTF-8?q?[Issues:=20#I9DC31]=20=E6=9B=B4=E6=96=B0react-n?= =?UTF-8?q?ative-canvas=E6=8C=87=E5=AF=BC=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1224/react-native-canvas.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/1224/react-native-canvas.md b/1224/react-native-canvas.md index 31eb0477..686144e3 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(); -- Gitee