From 9e7c47d71327c9311a156fda4ca49e714962d529 Mon Sep 17 00:00:00 2001 From: wuya_smile Date: Thu, 25 Apr 2024 15:42:19 +0800 Subject: [PATCH] =?UTF-8?q?[Issues:=20#I9HZSC]=20=E6=B7=BB=E5=8A=A0react-n?= =?UTF-8?q?ative-image-sequence=E6=93=8D=E4=BD=9C=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/react-native-image-sequence.md | 407 +++++++++++++++++++++++++++ 1 file changed, 407 insertions(+) create mode 100644 zh-cn/react-native-image-sequence.md diff --git a/zh-cn/react-native-image-sequence.md b/zh-cn/react-native-image-sequence.md new file mode 100644 index 00000000..7b37a2a9 --- /dev/null +++ b/zh-cn/react-native-image-sequence.md @@ -0,0 +1,407 @@ +> 模板版本:v0.1.3 + +

+

react-native-image-sequence

+

+

+ + Supported platforms + + + License + +

+ + +> [!tip] [Github 地址](https://github.com/react-native-oh-library/react-native-image-sequence) + +## 安装与使用 + +请到三方库的 Releases 发布地址查看配套的版本信息:[react-native-image-sequence Releases](https://github.com/react-native-oh-library/react-native-image-sequence/releases),并下载适用版本的 tgz 包 + +进入到工程目录并输入以下命令: + +> [!TIP] # 处替换为 tgz 包的路径 + + + +#### **npm** + +```bash +npm install @react-native-oh-tpl/react-native-image-sequence-2@file:# +``` + +#### **yarn** + +```bash +yarn add @react-native-oh-tpl/react-native-image-sequence-2@file:# +``` + + + +快速使用: + +> [!WARNING] 使用时 import 的库名不变。 + +```js +import React, { useState } from "react" +import { SafeAreaView, StyleSheet } from "react-native-harmony"; +import {View, Text, Switch, TextInput, Button} from 'react-native' +import TestDemo2 from "./TestDemo2"; + +const images = [ + {uri: 'https://octodex.github.com/images/stormtroopocat.jpg'}, + require('../../assets/2.jpg'), + require('../../assets/3.jpg'), + require('../../assets/4.jpg'), + require('../../assets/5.jpg'), + require('../../assets/6.jpg'), +] + +export interface sequenceType { + images: NodeRequire[], + loop: boolean, + startFrameIndex: number, + framesPerSecond: number, + downsampleWidth: number, + downsampleHeight: number +} + +const ImageSequenceDemo = (props: any) => { + const [loopData, setLoopData] = useState(false); + const [isShow, setIsShow] = useState(false); + const [winWidth, setWinWidth] = useState(300); + const [winHeight, setWinHeight] = useState(200); + const [downsampleWidth, setDownSampleWidth] = useState(-1); + const [downsampleHeight, setDownSampleHeight] = useState(-1); + + // 设置采样宽度 + const inputSampleWidth = (value: string) => { + if (isNaN(Number(value))) { + return; + } + setDownSampleWidth(Number(value)) + } + + // 设置采样高度 + const inputSampleGeight = (value: string) => { + if (isNaN(Number(value))) { + return; + } + setDownSampleHeight(Number(value)) + } + + // 设置起始位置 + const [startFrameIndex, setFrameIndex] = useState(0); + const inputStartFrameIndex = (value: string) => { + if (isNaN(Number(value))) { + return + } + let _value = Number(value) + if (Number(value) > images.length) { + _value = 0 + } + setFrameIndex(_value) + } + + // 设置速率 + const [framesPerSecond, setFramesPerSecond] = useState(24); + const inputFramesPerSecond = (value: string) => { + if (isNaN(Number(value))) { + return; + } + let _value = Number(value) + if (Number(value) <= 0) { + _value = 24 + } + setFramesPerSecond(_value) + } + + const buttonIsShow = () => { + setIsShow(!isShow) + } + + const inputSetWinWidth = (value:string) => { + if (isNaN(Number(value))) { + return; + } + setWinWidth(Number(value)) + } + + const inputSetWinHeight = (value: string) => { + if (isNaN(Number(value))) { + return; + } + setWinHeight(Number(value)) + } + + return ( + + + + Current view size:width: {winWidth}, height:{winHeight} + 开启循环: setLoopData(value)}> + + 图片宽度/高度: + + inputSetWinWidth(value)} defaultValue='300' keyboardType='numeric' /> + inputSetWinHeight(value)} defaultValue='200' keyboardType='numeric' /> + + + 开始位置:inputStartFrameIndex(value)} defaultValue="0" keyboardType="numeric"/> + 播放速度:inputFramesPerSecond(value)} defaultValue="24" keyboardType="numeric"/> + 采样宽度:inputSampleWidth(value)} defaultValue="-1" keyboardType="default"/> + 采样高度:inputSetWinHeight(value)} defaultValue="-1" keyboardType="default"/> + + { + !isShow?