@@ -44,10 +44,10 @@ deno install @selemondev/vue3-signature-pad
4444
4545## Usage
4646
47- ``` ts
47+ ``` vue
4848<script setup lang="ts">
49- import { VueSignaturePad } from " @selemondev/vue3-signature-pad"
50- import { onMounted , ref } from " vue" ;
49+ import { VueSignaturePad } from ' @selemondev/vue3-signature-pad'
50+ import { onMounted, ref } from ' vue'
5151
5252const state = ref({
5353 options: {
@@ -69,61 +69,73 @@ const colors = [
6969 {
7070 color: 'rgb(255, 85, 51)'
7171 }
72- ];
72+ ]
7373
74- const activeColor = ref ();
74+ const activeColor = ref()
7575
76- const signature = ref ();
76+ const signature = ref()
7777
78- const handleSave = (format ? : string ) => {
78+ function handleSave(format?: string) {
7979 return alert(signature.value.saveSignature(format))
80- };
81- const handleClear = () => {
80+ }
81+ function handleClear() {
8282 return signature.value.clearCanvas()
83- };
84- const handleUndo = () => {
83+ }
84+ function handleUndo() {
8585 return signature.value.undo()
86- };
87-
88- const handleDisabled = () => {
89- return state .value .disabled = ! state .value .disabled ;
90- };
91-
92- const handleFromDataURL = (url : string ) => {
93- return signature .value .fromDataURL (url );
94- };
95-
96- const handleAddWaterMark = () => {
97- return signature .value .addWaterMark ({
98- text: " Selemondev" , // watermark text, > default ''
99- font: " 20px Arial" , // mark font, > default '20px sans-serif'
100- style: ' all' , // fillText and strokeText, 'all'/'stroke'/'fill', > default 'fill
101- fillStyle: " red" , // fillcolor, > default '#333'
102- strokeStyle: " blue" , // strokecolor, > default '#333'
103- x: 100 , // fill positionX, > default 20
104- y: 200 , // fill positionY, > default 20
105- sx: 100 , // stroke positionX, > default 40
106- sy: 200 // stroke positionY, > default 40
107- });
86+ }
87+
88+ function handleDisabled() {
89+ return state.value.disabled = !state.value.disabled
90+ }
91+
92+ function handleFromDataURL(url: string) {
93+ return signature.value.fromDataURL(url)
94+ }
95+
96+ function handleAddWaterMark() {
97+ return signature.value.addWaterMark({
98+ text: ' Selemondev', // watermark text, > default ''
99+ font: ' 20px Arial', // mark font, > default '20px sans-serif'
100+ style: 'all', // fillText and strokeText, 'all'/'stroke'/'fill', > default 'fill
101+ fillStyle: ' red', // fillcolor, > default '#333'
102+ strokeStyle: ' blue', // strokecolor, > default '#333'
103+ x: 100, // fill positionX, > default 20
104+ y: 200, // fill positionY, > default 20
105+ sx: 100, // stroke positionX, > default 40
106+ sy: 200 // stroke positionY, > default 40
107+ })
108108}
109109</script>
110110
111111<template>
112112 <div class="grid place-items-center w-full min-h-screen">
113113 <div class="flex flex-col items-center space-y-4">
114114 <div class="bg-gray-100 p-6">
115- < VueSignaturePad ref = " signature" height = " 400px" width = " 1280px" :maxWidth = " 2" :minWidth = " 2"
116- :disabled = " state.disabled" / >
115+ <VueSignaturePad
116+ ref="signature" height="400px" width="1280px" :max-width="2" :min-width="2"
117+ :disabled="state.disabled"
118+ />
117119 </div>
118120
119- < button type = " button" @click = " handleSave('image/jpeg')" > Save < / button >
120- < button type = " button" @click = " handleClear" > Clear < / button >
121- < button type = " button" @click = " handleUndo" > Undo < / button >
122- < button type = " button" @click = " handleDisabled" > Disabled < / button >
123- < button type = " button" @click = " handleFromDataURL('https://github.com/selemondev.png')" >
124- FromData URL
125- < / button >
126- < button type = " button" @click = " handleAddWaterMark" > Add watermark < / button >
121+ <button type="button" @click="handleSave('image/jpeg')">
122+ Save
123+ </button>
124+ <button type="button" @click="handleClear">
125+ Clear
126+ </button>
127+ <button type="button" @click="handleUndo">
128+ Undo
129+ </button>
130+ <button type="button" @click="handleDisabled">
131+ Disabled
132+ </button>
133+ <button type="button" @click="handleFromDataURL('https://github.com/selemondev.png')">
134+ FromData URL
135+ </button>
136+ <button type="button" @click="handleAddWaterMark">
137+ Add watermark
138+ </button>
127139 </div>
128140 </div>
129141</template>
0 commit comments