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 (
    <Signature
      defaultPoints={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 (
    <Signature
      defaultPoints={points}
      options={{
        size: 6,
      }}
      renderPath={(path, keyName) => {
          return (
            <>
              <path
                d={path}
                strokeWidth="3"
                stroke="blue"
                fill="transparent"
                strokeLinejoin="round"
                strokeLinecap="round"
                pointerEvents="all"
              />
              <path
                d={path}
                strokeWidth="0"
                stroke="transparent"
                fill="#dadada"
                strokeLinejoin="round"
                strokeLinecap="round"
                pointerEvents="all"
              />
            </>
          )
      }}
    />
  );
}

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

重写equals为什么要重写hashCode

答&#xff1a;因为两个相等的对象的 hashCode值必须是相等。也就是说如果equals方法判断两个对象是相等的&#xff0c;那这两个对象的hashCode值也要相等。 如果重写equals()时没有重写 hashCode()方法的话就可能会导致equals方法判断是相等的两个对象&#xff0c;hashcode值…

LabVIEW通过编程将图形类控件的X轴显示为时间戳

LabVIEW通过编程将图形类控件的X轴显示为时间戳 每个版本的LabVIEW中都有属性节点&#xff0c;可以以编程方式调整X轴和Y轴格式。对于不同版本的LabVIEW&#xff0c;这些属性节点无法在同一个位置找到。请参阅以下部分&#xff0c;了解特定版本LabVIEW的相关属性节点的位置。 …

供应商关系管理软件:如何使用它来改善供应商关系?

从最基本的角度来说&#xff0c;企业需要供应商为其生产和销售的产品或服务提供原材料&#xff0c;或者为其提供资源和服务来经营自己的业务。 建立稳定而健康的供应商关系的最大优势之一&#xff0c;就是可以为企业带来更高的价值。企业对供应商了解越多&#xff0c;供应商对…

强基固本,红海云数字化重塑提升国企干部管理能力

国有企业的干部管理体系建设具有重要的战略意义&#xff0c;对于构建高素质专业化的干部队伍&#xff0c;推动企业高质量发展至关重要。特别是在党的二十大以后&#xff0c;建设中国特色现代企业制度&#xff0c;在完善公司治理中加强党的领导&#xff0c;加强党管干部党管人才…

全球市场:跨境电商消费者权益维权的趋势

随着数字技术的迅猛发展&#xff0c;跨境电商逐渐成为全球贸易的引领者&#xff0c;但与此同时&#xff0c;消费者权益维权问题也备受关注。本文将深入探讨跨境电商消费者权益维权的趋势&#xff0c;剖析全球市场中涌现的挑战和解决方案&#xff0c;以期为构建更加公平、透明的…

GoWeb学习-第二天

文章目录 从零开始学Go web——第二天一、安装Go语言二、建立web目录2.1 创建GO语言包目录2.2 创建Go web文件 三、编译并运行Go web应用3.1 编译并运行3.2 查看结果 从零开始学Go web——第二天 ​ 第一天我们了解了与web息息相关的HTTP协议&#xff0c;聊了聊Go与web的关系等…

struts2 代码执行 (CVE-2020-17530)

struts2 代码执行 &#xff08;CVE-2020-17530&#xff09; 使用struts2框架的网站 URL上会有.action结尾这个特征 名称: struts2 代码执行 &#xff08;CVE-2020-17530&#xff09; 描述: Struts2是一个基于MVC设计模式的Web应用框架&#xff0c;它本质上相当于一个servlet…

PM2 在线和离线部署uvicorn和fastapi项目过程

PM2介绍 PM2 is a daemon process manager that will help you manage and keep your application online 24/7 PM2是一个后台进程管理工具&#xff0c;能帮助管理应用和维持应用7*24小时运行。 PM2在线安装 npm install pm2 -gPM2离线安装(适用于内网) 参见 如何离线安装pm2…

算法通关村第二关—手写链表反转(青铜)

链表反转的三种方式 一、建立虚拟头结点辅助反转 为了方便反转&#xff0c;可以创建一个ans结点&#xff0c;让ans.next head,然后后面的结点一次插入到ans.next 在下图中&#xff0c;对&#xff08;1->2->3->4->5&#xff09;进行反转&#xff0c;可以创建ans&…

马骑顿部署实在RPA,所产价值超该项目投入6倍

“数字化最大的挑战在于我们增长太快了&#xff0c;对于全域经营的DTC品牌来说&#xff0c;让一个部门去管理所有平台数据&#xff0c;形成品牌全域生意的协同实非易事。”马骑顿运营部负责人表示。2022年&#xff0c;马骑顿搭建企业数据中台&#xff0c;统一管理线上数据&…

wsj0数据集原始文件.wv1.wv2转换成wav文件

文章目录 准备一、获取WSJO数据集二、安装sph2pipe三、转换代码四、结果展示 ​ 最近做语音分离实验需要用到wsj0-2mix数据集&#xff0c;但是从李宏毅语音分离教程里面获取的wsj0-2mix只有一部分。从网上获取到了完整的WSJO数据集后&#xff0c;由于原始的语音文件后缀是wv1或…

网关路由器双栈配置中的IPv6相关选项解析

1、引言 讲知识往往是枯燥无味的&#xff0c;我们先从问题入手。家庭网关&#xff08;光猫&#xff09;、路由器是我们每个人或多或少都有所接触的2种设备。现在一般都是光纤入户&#xff0c;通常每个家庭配备一个光猫和一台家用路由器。 目前有许多网络服务已经提供了IPv6支…

距离“全自动”漏洞挖掘又近了一步!腾讯安全大数据实验室论文入选ACM CCS 2023

计算机领域国际权威学术顶会ACM CCS 2023于11月26日在丹麦哥本哈根开幕。腾讯安全大数据实验室团队论文《Hopper: Interpretative Fuzzing for Libraries》被大会收录&#xff0c;昨天&#xff0c;实验室研究员谢雨轩受邀出席大会进行主题分享。 该论文提出了解释性模糊测试&a…

前端笔试遇到的坑-100题

1.闭包 let 形成闭包 var全局变量 function test() {for (var i 0; i < 6; i) {console.log(i); //1 2 3 4 5 6// setTimeout(() > {// console.log(i);// }, 0); 6 6 6 6 6 6 6} } test();var array []; for (var i 0; i < 3; i) {array.push(() > i);…

全国高校走进深算院:共话国产数据库产教融合生态建设

近日&#xff0c;由教育部高等学校计算机类专业教学指导委员会、全国高等学校计算机教育研究会主办&#xff0c;清华大学出版社、深圳市信息技术应用创新联盟承办的“2023全国高校走进信创企业研学活动”顺利举办。来自全国各地30余家高校的近80位院校领导、教师代表走进了深圳…

WordPress更改文章分类插件

当WP网站内容比较多的时候&#xff0c;有时候如果涉及到批量修改文章分类&#xff0c;如果一个个的去操作的话就太费事了&#xff0c;如果使用后台批量修改分类的话是增加旧分类不会取消选择&#xff0c;就就导致我们适得其反还需要一个一个的去编辑取消&#xff0c;实在繁琐了…

年终好价节有什么必买的数码好物?值得入手的数码好物推荐

大家是不是都没听说过好价节&#xff1f;直白点说就是原来的双十二购物狂欢节&#xff0c;只不过换一个说法&#xff0c;不过今年毕竟是第一年换个说法&#xff0c;所以淘宝年终好价节优惠还是值得我们期待的&#xff01;作为年前的最后一波大促&#xff0c;一起来看看有哪些好…

redis 内存机制探索篇

info memory 查看redis 内存使用情况出现的问题&#xff0c;公司在导入大量redis key 的时候&#xff0c;想要看一下redis 内存使用情况 &#xff0c;发现used_memory_peak_perc 和 used_memory_dataset_perc 马上达到100%&#xff0c;这个时候很慌张&#xff0c;是不是当前red…

智能AI问答系统ChatGPT网站系统源码+Midjourney绘画+支持GPT-4-Turbo模型+支持GPT-4图片理解能力

一、AI创作系统 SparkAi创作系统是基于ChatGPT进行开发的Ai智能问答系统和Midjourney绘画系统&#xff0c;支持OpenAI-GPT全模型国内AI全模型。本期针对源码系统整体测试下来非常完美&#xff0c;可以说SparkAi是目前国内一款的ChatGPT对接OpenAI软件系统。那么如何搭建部署AI…

亚马逊发布人工智能助手Amazon Q,一起来看看有什么功能

Amazon 在11.28日Re:Invent大会上推出人工智能助手Amazon Q&#xff0c;主要面向企业客户&#xff0c;提供个性化服务。号称是专为工作定制的生成式人工智能助手。Your generative Al-powered assistant tailored for work 核心能力企业知识库&#xff1a;为客户提供快速、相关…