1.4.0 • Published 5 months ago

v-perfect-signature v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

v-perfect-signature

Pressure-sensitive signature drawing for Vue 2 and 3 built on top of perfect-freehand.

Demo: https://wobsoriano.github.io/v-perfect-signature

Install

pnpm add v-perfect-signature

Usage

<script setup>
import { ref } from 'vue'
import { VPerfectSignature } from 'v-perfect-signature'

const signaturePad = ref()
const strokeOptions = {
  size: 16,
  thinning: 0.75,
  smoothing: 0.5,
  streamline: 0.5,
}

function toDataURL() {
  const dataURL = signaturePad.value.toDataURL()
  console.log(dataURL)
}
</script>

<template>
  <VPerfectSignature ref="signaturePad" :stroke-options="strokeOptions" />
</template>

Props

NameTypeDefaultDescription
widthString100%Set canvas width
heightString100%Set canvas height
backgroundColorStringrgba(0,0,0,0)Canvas background color
penColorString#000Canvas pen color
strokeOptionsObjectReferencePerfect freehand options

Methods

NameArgument TypeDescription
toDataURL(type)StringReturns signature image as data URL
fromDataURL(dataUri)StringDraws signature image from data URL
toData-Returns signature image as an array of array of input points
fromData(data)ArrayDraws signature image from array of array of input points
clear()-Clears the canvas
isEmpty()-Returns true if canvas is empty
resizeCanvas(shouldClear)BooleanResizes and recalculate dimensions

Note: Like signature_pad, fromDataURL does not populate internal data structure. Thus, after using fromDataURL, toData won't work properly.

Events

NameTypeDefaultDescription
onBeginFunction-Fired when stroke begin
onEndFunction-Fired when stroke end

Nuxt

export default defineNuxtConfig({
  build: {
    transpile: ['v-perfect-signature']
  }
})

License

MIT

1.4.0

5 months ago

1.2.0

11 months ago

1.3.0

7 months ago

1.2.1

11 months ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

3 years ago

0.0.1

3 years ago