All Projects → agilgur5 → react-signature-canvas

agilgur5 / react-signature-canvas

Licence: other
A React wrapper component around signature_pad (in < 150 LoC). Unopinionated and heavily updated fork of react-signature-pad

Projects that are alternatives of or similar to react-signature-canvas

trim-canvas
A tiny (< 100 LoC) library for trimming whitespace from a canvas element with no dependencies
Stars: ✭ 48 (-88.57%)
Mutual labels:  signature, trim, whitespace
Signature pad
HTML5 canvas based smooth signature drawing
Stars: ✭ 7,623 (+1715%)
Mutual labels:  signature, signature-pad
Buddy Sign
High level message signing library.
Stars: ✭ 86 (-79.52%)
Mutual labels:  signature
Creepycodecollection
A Nonsense Collection of Disgusting Codes
Stars: ✭ 2,206 (+425.24%)
Mutual labels:  signature
Androidsecurity
Android安全实践
Stars: ✭ 150 (-64.29%)
Mutual labels:  signature
Piracychecker
An Android library that prevents your app from being pirated / cracked using Google Play Licensing (LVL), APK signature protection and more. API 14+ required.
Stars: ✭ 1,359 (+223.57%)
Mutual labels:  signature
Loki
Loki - Simple IOC and Incident Response Scanner
Stars: ✭ 2,217 (+427.86%)
Mutual labels:  signature
Signature Base
Signature base for my scanner tools
Stars: ✭ 1,212 (+188.57%)
Mutual labels:  signature
Jsrsasign
The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES JSON Web Signature/Token in pure JavaScript.
Stars: ✭ 2,760 (+557.14%)
Mutual labels:  signature
Nauz File Detector
Linker/Compiler/Tool detector for Windows, Linux and MacOS.
Stars: ✭ 146 (-65.24%)
Mutual labels:  signature
Easyrsa
Simple and Secure Wrapper for phpseclib
Stars: ✭ 183 (-56.43%)
Mutual labels:  signature
Sarkara
[unmaintenance] A experimental post-quantum cryptography library
Stars: ✭ 139 (-66.9%)
Mutual labels:  signature
Ramda Debug
🐏 Debugging for Ramda.
Stars: ✭ 113 (-73.1%)
Mutual labels:  signature
React Native Signature Canvas
✒️ React Native Signature Component based WebView Canvas for Android && IOS && expo
Stars: ✭ 169 (-59.76%)
Mutual labels:  signature
Roslynpad
A cross-platform C# editor based on Roslyn and AvalonEdit
Stars: ✭ 1,310 (+211.9%)
Mutual labels:  signature
Auth Jwt
A demo to learn JWT by reverse engineering
Stars: ✭ 208 (-50.48%)
Mutual labels:  signature
Direct Upload
Composer Package to Direct Upload to S3
Stars: ✭ 84 (-80%)
Mutual labels:  signature
Stunning Signature
Native Signature Verification For Android (with example)
Stars: ✭ 139 (-66.9%)
Mutual labels:  signature
Jose2go
Golang (GO) implementation of Javascript Object Signing and Encryption specification
Stars: ✭ 150 (-64.29%)
Mutual labels:  signature
Expo Pixi
Tools for using pixi.js in Expo
Stars: ✭ 253 (-39.76%)
Mutual labels:  signature

react-signature-canvas

package-json releases commits
dt dy dm dw
typings build status code coverage
NPM
A React wrapper component around signature_pad.

Originally, this was just an unopinionated fork of react-signature-pad that did not impose any styling or wrap any other unwanted elements around your canvas -- it's just a wrapper around a single canvas element! Hence the naming difference. Nowadays, this repo / library has significantly evolved, introducing new features, fixing various bugs, and now wrapping the upstream signature_pad to have its updates and bugfixes baked in.

This fork also allows you to directly pass props to the underlying canvas element, has new, documented API methods you can use, has new, documented props you can pass to it, has a live demo, has a CodeSandbox playground, has 100% test coverage, and is written in TypeScript.

Installation

npm i -S react-signature-canvas

Usage

import React from 'react'
import ReactDOM from 'react-dom'
import SignatureCanvas from 'react-signature-canvas'

ReactDOM.render(
  <SignatureCanvas penColor='green'
    canvasProps={{width: 500, height: 200, className: 'sigCanvas'}} />,
  document.getElementById('react-container')
)

Props

The props of SignatureCanvas mainly control the properties of the pen stroke used in drawing. All props are optional.

  • velocityFilterWeight : number, default: 0.7
  • minWidth : number, default: 0.5
  • maxWidth : number, default: 2.5
  • minDistance: number, default: 5
  • dotSize : number or function, default: () => (this.minWidth + this.maxWidth) / 2
  • penColor : string, default: 'black'
  • throttle: number, default: 16

There are also two callbacks that will be called when a stroke ends and one begins, respectively.

  • onEnd : function
  • onBegin : function

Additional props are used to control the canvas element.

  • canvasProps: object
    • directly passed to the underlying <canvas /> element
  • backgroundColor : string, default: 'rgba(0,0,0,0)'
    • used in the API's clear convenience method (which itself is called internally during resizes)
  • clearOnResize: bool, default: true
    • whether or not the canvas should be cleared when the window resizes

Of these props, all, except for canvasProps and clearOnResize, are passed through to signature_pad as its options. signature_pad's internal state is automatically kept in sync with prop updates for you (via a componentDidUpdate hook).

API

All API methods require a ref to the SignatureCanvas in order to use and are instance methods of the ref.

<SignatureCanvas ref={(ref) => { this.sigCanvas = ref }} />
  • isEmpty() : boolean, self-explanatory
  • clear() : void, clears the canvas using the backgroundColor prop
  • fromDataURL(base64String, options) : void, writes a base64 image to canvas
  • toDataURL(mimetype, encoderOptions): base64string, returns the signature image as a data URL
  • fromData(pointGroupArray): void, draws signature image from an array of point groups
  • toData(): pointGroupArray, returns signature image as an array of point groups
  • off(): void, unbinds all event handlers
  • on(): void, rebinds all event handlers
  • getCanvas(): canvas, returns the underlying canvas ref. Allows you to modify the canvas however you want or call methods such as toDataURL()
  • getTrimmedCanvas(): canvas, creates a copy of the canvas and returns a trimmed version of it, with all whitespace removed.
  • getSignaturePad(): SignaturePad, returns the underlying SignaturePad reference.

The API methods are mostly just wrappers around signature_pad's API. on() and off() will, in addition, bind/unbind the window resize event handler. getCanvas(), getTrimmedCanvas(), and getSignaturePad() are new.

Example

You can interact with the example in a few different ways:

  1. Run npm start and navigate to http://localhost:1234/.
    Hosted locally via the example/ directory
  2. View the live demo here.
    Hosted via the gh-pages branch, a standalone version of the code in example/
  3. Play with the CodeSandbox here.
    Hosted via the cra-example branch, a standalone version using Create React App.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].