qrcode.vue 3.5.1 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README-zh_cn.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  一款 Vue.js 二维码组件,同时支持 Vue 2 和 Vue 3.
8
8
 
9
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/scopewu/qrcode.vue/blob/master/LICENSE)
9
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/scopewu/qrcode.vue/blob/main/LICENSE)
10
10
 
11
11
  ## 快速开始
12
12
 
@@ -76,13 +76,17 @@ createApp({
76
76
  :render-as="renderAs"
77
77
  :background="background"
78
78
  :foreground='foreground'
79
+ :gradient="gradient"
80
+ :gradient-type="gradientType"
81
+ :gradient-start-color="gradientStartColor"
82
+ :gradient-end-color="gradientEndColor"
79
83
  :image-settings='imageSettings'
80
84
  />
81
85
  </template>
82
86
  <script setup lang="ts">
83
87
  import { ref } from 'vue'
84
88
  import QrcodeVue from 'qrcode.vue'
85
- import type { Level, RenderAs, ImageSettings } from 'qrcode.vue'
89
+ import type { Level, RenderAs, GradientType, ImageSettings } from 'qrcode.vue'
86
90
 
87
91
  const value = ref('qrcode')
88
92
  const level = ref<Level>('M')
@@ -90,6 +94,8 @@ createApp({
90
94
  const background = ref('#ffffff')
91
95
  const foreground = ref('#000000')
92
96
  const margin = ref(0)
97
+
98
+ // 可传入二维码图片相关的属性,支持二维码 LOGO;
93
99
  const imageSettings = ref<ImageSettings>({
94
100
  src: 'https://github.com/scopewu.png',
95
101
  width: 30,
@@ -98,6 +104,12 @@ createApp({
98
104
  // y: 10,
99
105
  excavate: true,
100
106
  })
107
+
108
+ // 可传入渐变相关的属性,支持渐变:
109
+ const gradient = ref(false)
110
+ const gradientType = ref<GradientType>('linear')
111
+ const gradientStartColor = ref('#000000')
112
+ const gradientEndColor = ref('#38bdf8')
101
113
  </script>
102
114
  ```
103
115
 
@@ -168,11 +180,40 @@ createApp({
168
180
  // 这意味着嵌入图像重叠的任何模块都将使用背景颜色。
169
181
  // 使用此选项可确保图像周围的边缘清晰。嵌入透明图像时也很有用。
170
182
  excavate?: boolean,
183
+ borderRadius?: number, // 图片的边框圆角。
171
184
  }
172
185
  ```
173
186
 
174
187
  二维码图片 logo 配置。
175
188
 
189
+ ### `gradient`
190
+
191
+ - 类型: `boolean`
192
+ - 默认值: `false`
193
+
194
+ 启用二维码的渐变填充。
195
+
196
+ ### `gradient-type`
197
+
198
+ - 类型: `GradientType('linear' | 'radial')`
199
+ - 默认值: `linear`
200
+
201
+ 指定渐变类型。
202
+
203
+ ### `gradient-start-color`
204
+
205
+ - 类型: `string`
206
+ - 默认值: `#000000`
207
+
208
+ 渐变的起始颜色。
209
+
210
+ ### `gradient-end-color`
211
+
212
+ - 类型: `string`
213
+ - 默认值: `#ffffff`
214
+
215
+ 渐变的结束颜色。
216
+
176
217
  ### `class`
177
218
 
178
219
  - 类型:`string`
@@ -191,20 +232,20 @@ createApp({
191
232
  + exports: 'named',
192
233
  ```
193
234
 
194
-
195
235
  现在在 common.js 和 cdn 直接引用 `QrcodeVue` 需要使用 `default` 字段:
196
236
 
197
237
  ```js
198
238
  const QrcodeVue = require('qrcode.vue').default
199
239
  const { default: QrcodeVue, QrcodeCanvas, QrcodeSvg } = require('qrcode.vue')
200
240
  ```
241
+
201
242
  ```html
202
243
  <!--With HTML-->
203
244
  <div id="root">
204
245
  <p class="flex space-x">
205
246
  <qrcode-vue :value="test" render-as="svg"></qrcode-vue>
206
- <qrcode-canvas :value="test"></qrcode-canvas>
207
- </p>
247
+ <qrcode-canvas :value="test"></qrcode-canvas>
248
+ </p>
208
249
  <p><input v-model="test" /></p>
209
250
  </div>
210
251
  <script src="https://cdn.jsdelivr.net/npm/vue@3.5/dist/vue.global.prod.js"></script>
package/README.md CHANGED
@@ -6,8 +6,6 @@
6
6
 
7
7
  A Vue.js component to generate [QRCode](https://en.wikipedia.org/wiki/QR_code). Both support Vue 2 and Vue 3.
8
8
 
9
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/scopewu/qrcode.vue/blob/master/LICENSE)
10
-
11
9
  [中文](./README-zh_cn.md) | [日本語](./README-ja.md)
12
10
 
13
11
  ## install
@@ -82,13 +80,17 @@ When you use the component with Vue 3 with `TypeScript`:
82
80
  :render-as="renderAs"
83
81
  :background="background"
84
82
  :foreground='foreground'
83
+ :gradient="gradient"
84
+ :gradient-type="gradientType"
85
+ :gradient-start-color="gradientStartColor"
86
+ :gradient-end-color="gradientEndColor"
85
87
  :image-settings='imageSettings'
86
88
  />
87
89
  </template>
88
90
  <script setup lang="ts">
89
91
  import { ref } from 'vue'
90
92
  import QrcodeVue from 'qrcode.vue'
91
- import type { Level, RenderAs, ImageSettings } from 'qrcode.vue'
93
+ import type { Level, RenderAs, GradientType, ImageSettings } from 'qrcode.vue'
92
94
 
93
95
  const value = ref('qrcode')
94
96
  const level = ref<Level>('M')
@@ -96,6 +98,7 @@ When you use the component with Vue 3 with `TypeScript`:
96
98
  const background = ref('#ffffff')
97
99
  const foreground = ref('#000000')
98
100
  const margin = ref(0)
101
+
99
102
  const imageSettings = ref<ImageSettings>({
100
103
  src: 'https://github.com/scopewu.png',
101
104
  width: 30,
@@ -104,6 +107,11 @@ When you use the component with Vue 3 with `TypeScript`:
104
107
  // y: 10,
105
108
  excavate: true,
106
109
  })
110
+
111
+ const gradient = ref(false)
112
+ const gradientType = ref<GradientType>('linear')
113
+ const gradientStartColor = ref('#000000')
114
+ const gradientEndColor = ref('#38bdf8')
107
115
  </script>
108
116
  ```
109
117
 
@@ -171,11 +179,40 @@ The foreground color of qrcode.
171
179
  height: number, // The height of image
172
180
  width: number, // The height of image
173
181
  excavate?: boolean, // Whether or not to "excavate" the modules around the image.
182
+ borderRadius?: number, // The border radius of image.
174
183
  }
175
184
  ```
176
185
 
177
186
  The settings to support qrcode image logo.
178
187
 
188
+ ### `gradient`
189
+
190
+ - Type: `boolean`
191
+ - Default: `false`
192
+
193
+ Enable gradient fill for the QR code.
194
+
195
+ ### `gradient-type`
196
+
197
+ - Type: `GradientType('linear' | 'radial')`
198
+ - Default: `linear`
199
+
200
+ Specify the type of gradient.
201
+
202
+ ### `gradient-start-color`
203
+
204
+ - Type: `string`
205
+ - Default: `#000000`
206
+
207
+ The start color of the gradient.
208
+
209
+ ### `gradient-end-color`
210
+
211
+ - Type: `string`
212
+ - Default: `#ffffff`
213
+
214
+ The end color of the gradient.
215
+
179
216
  ### `class`
180
217
 
181
218
  - Type: `string`
@@ -200,14 +237,15 @@ Direct references to `QrcodeVue` in common.js and cdn now require the `default`
200
237
  const QrcodeVue = require('qrcode.vue').default
201
238
  const { default: QrcodeVue, QrcodeCanvas, QrcodeSvg } = require('qrcode.vue')
202
239
  ```
240
+
203
241
  ```html
204
242
  <!--With HTML-->
205
243
  <div id="root">
206
244
  <p class="flex space-x">
207
245
  <qrcode-vue :value="test" render-as="svg"></qrcode-vue>
208
- <qrcode-canvas :value="test"></qrcode-canvas>
209
- </p>
210
- <p><input v-model="test" /></p>
246
+ <qrcode-canvas :value="test"></qrcode-canvas>
247
+ </p>
248
+ <p><input v-model="test" /></p>
211
249
  </div>
212
250
  <script src="https://cdn.jsdelivr.net/npm/vue@3.5/dist/vue.global.prod.js"></script>
213
251
  <script src="https://cdn.jsdelivr.net/npm/qrcode.vue@3.5/dist/qrcode.vue.browser.min.js"></script>
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * qrcode.vue v3.5.1
2
+ * qrcode.vue v3.7.0
3
3
  * A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3
4
4
  * © 2017-PRESENT @scopewu(https://github.com/scopewu)
5
5
  * MIT License.
@@ -24,7 +24,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
24
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
25
  PERFORMANCE OF THIS SOFTWARE.
26
26
  ***************************************************************************** */
27
- /* global Reflect, Promise, SuppressedError, Symbol */
27
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
28
28
 
29
29
 
30
30
  var __assign = function() {
@@ -910,6 +910,9 @@ var qrcodegen;
910
910
  var QR = qrcodegen;
911
911
 
912
912
  var defaultErrorCorrectLevel = 'L';
913
+ var DEFAULT_QR_SIZE = 100;
914
+ var DEFAULT_MARGIN = 0;
915
+ var DEFAULT_IMAGE_SIZE_RATIO = 0.1;
913
916
  var ErrorCorrectLevelMap = {
914
917
  L: QR.QrCode.Ecc.LOW,
915
918
  M: QR.QrCode.Ecc.MEDIUM,
@@ -929,16 +932,52 @@ var SUPPORTS_PATH2D = (function () {
929
932
  function validErrorCorrectLevel(level) {
930
933
  return level in ErrorCorrectLevelMap;
931
934
  }
935
+ function isPointInRoundedRect(px, py, rx, ry, rw, rh, r) {
936
+ // Fast check: point outside the bounding box
937
+ if (px < rx || px > rx + rw || py < ry || py > ry + rh) {
938
+ return false;
939
+ }
940
+ // If no border radius or point is in the center rectangle
941
+ if (r <= 0 || (px > rx + r && px < rx + rw - r) || (py > ry + r && py < ry + rh - r)) {
942
+ return true;
943
+ }
944
+ // Check the four corners
945
+ // Top-left corner
946
+ if (px < rx + r && py < ry + r) {
947
+ var dx = px - (rx + r);
948
+ var dy = py - (ry + r);
949
+ return dx * dx + dy * dy <= r * r;
950
+ }
951
+ // Top-right corner
952
+ if (px > rx + rw - r && py < ry + r) {
953
+ var dx = px - (rx + rw - r);
954
+ var dy = py - (ry + r);
955
+ return dx * dx + dy * dy <= r * r;
956
+ }
957
+ // Bottom-left corner
958
+ if (px < rx + r && py > ry + rh - r) {
959
+ var dx = px - (rx + r);
960
+ var dy = py - (ry + rh - r);
961
+ return dx * dx + dy * dy <= r * r;
962
+ }
963
+ // Bottom-right corner
964
+ if (px > rx + rw - r && py > ry + rh - r) {
965
+ var dx = px - (rx + rw - r);
966
+ var dy = py - (ry + rh - r);
967
+ return dx * dx + dy * dy <= r * r;
968
+ }
969
+ return true;
970
+ }
932
971
  function generatePath(modules, margin) {
933
972
  if (margin === void 0) { margin = 0; }
934
- var ops = [];
973
+ var path = '';
935
974
  modules.forEach(function (row, y) {
936
975
  var start = null;
937
976
  row.forEach(function (cell, x) {
938
977
  if (!cell && start !== null) {
939
978
  // M0 0h7v1H0z injects the space with the move and drops the comma,
940
979
  // saving a char per operation
941
- ops.push("M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z"));
980
+ path += "M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z");
942
981
  start = null;
943
982
  return;
944
983
  }
@@ -951,11 +990,11 @@ function generatePath(modules, margin) {
951
990
  }
952
991
  if (start === null) {
953
992
  // Just a single dark module.
954
- ops.push("M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z"));
993
+ path += "M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z");
955
994
  }
956
995
  else {
957
996
  // Otherwise finish the current line.
958
- ops.push("M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z"));
997
+ path += "M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z");
959
998
  }
960
999
  return;
961
1000
  }
@@ -964,12 +1003,12 @@ function generatePath(modules, margin) {
964
1003
  }
965
1004
  });
966
1005
  });
967
- return ops.join('');
1006
+ return path;
968
1007
  }
969
1008
  function getImageSettings(cells, size, margin, imageSettings) {
970
1009
  var width = imageSettings.width, height = imageSettings.height, imageX = imageSettings.x, imageY = imageSettings.y;
971
1010
  var numCells = cells.length + margin * 2;
972
- var defaultSize = Math.floor(size * 0.1);
1011
+ var defaultSize = Math.floor(size * DEFAULT_IMAGE_SIZE_RATIO);
973
1012
  var scale = numCells / size;
974
1013
  var w = (width || defaultSize) * scale;
975
1014
  var h = (height || defaultSize) * scale;
@@ -981,20 +1020,34 @@ function getImageSettings(cells, size, margin, imageSettings) {
981
1020
  var floorY = Math.floor(y);
982
1021
  var ceilW = Math.ceil(w + x - floorX);
983
1022
  var ceilH = Math.ceil(h + y - floorY);
984
- excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
1023
+ var borderRadius = (imageSettings.borderRadius || 0) * scale;
1024
+ excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH, borderRadius: borderRadius };
985
1025
  }
986
1026
  return { x: x, y: y, h: h, w: w, excavation: excavation };
987
1027
  }
988
1028
  function excavateModules(modules, excavation) {
989
- return modules.slice().map(function (row, y) {
990
- if (y < excavation.y || y >= excavation.y + excavation.h) {
991
- return row;
992
- }
1029
+ var borderRadius = excavation.borderRadius;
1030
+ // If no border radius, use simple rectangular excavation
1031
+ if (!borderRadius || borderRadius <= 0) {
1032
+ return modules.map(function (row, y) {
1033
+ if (y < excavation.y || y >= excavation.y + excavation.h) {
1034
+ return row;
1035
+ }
1036
+ return row.map(function (cell, x) {
1037
+ if (x < excavation.x || x >= excavation.x + excavation.w) {
1038
+ return cell;
1039
+ }
1040
+ return false;
1041
+ });
1042
+ });
1043
+ }
1044
+ // For rounded corners, check each module against the rounded rectangle shape
1045
+ return modules.map(function (row, y) {
993
1046
  return row.map(function (cell, x) {
994
- if (x < excavation.x || x >= excavation.x + excavation.w) {
1047
+ if (!cell)
995
1048
  return cell;
996
- }
997
- return false;
1049
+ var inExcavation = isPointInRoundedRect(x + 0.5, y + 0.5, excavation.x, excavation.y, excavation.w, excavation.h, borderRadius);
1050
+ return inExcavation ? false : cell;
998
1051
  });
999
1052
  });
1000
1053
  }
@@ -1006,7 +1059,7 @@ var QRCodeProps = {
1006
1059
  },
1007
1060
  size: {
1008
1061
  type: Number,
1009
- default: 100,
1062
+ default: DEFAULT_QR_SIZE,
1010
1063
  },
1011
1064
  level: {
1012
1065
  type: String,
@@ -1024,13 +1077,34 @@ var QRCodeProps = {
1024
1077
  margin: {
1025
1078
  type: Number,
1026
1079
  required: false,
1027
- default: 0,
1080
+ default: DEFAULT_MARGIN,
1028
1081
  },
1029
1082
  imageSettings: {
1030
1083
  type: Object,
1031
1084
  required: false,
1032
1085
  default: function () { return ({}); },
1033
1086
  },
1087
+ gradient: {
1088
+ type: Boolean,
1089
+ required: false,
1090
+ default: false,
1091
+ },
1092
+ gradientType: {
1093
+ type: String,
1094
+ required: false,
1095
+ default: 'linear',
1096
+ validator: function (t) { return ['linear', 'radial'].indexOf(t) > -1; },
1097
+ },
1098
+ gradientStartColor: {
1099
+ type: String,
1100
+ required: false,
1101
+ default: '#000',
1102
+ },
1103
+ gradientEndColor: {
1104
+ type: String,
1105
+ required: false,
1106
+ default: '#fff',
1107
+ },
1034
1108
  };
1035
1109
  var QRCodeVueProps = __assign(__assign({}, QRCodeProps), { renderAs: {
1036
1110
  type: String,
@@ -1071,8 +1145,53 @@ var QrcodeSvg = vue.defineComponent({
1071
1145
  // For level 40, 31329 -> 2
1072
1146
  fgPath.value = generatePath(cells, margin);
1073
1147
  };
1148
+ var renderGradient = function () {
1149
+ if (!props.gradient)
1150
+ return null;
1151
+ var gradientProps = props.gradientType === 'linear'
1152
+ ? {
1153
+ x1: '0%',
1154
+ y1: '0%',
1155
+ x2: '100%',
1156
+ y2: '100%',
1157
+ }
1158
+ : {
1159
+ cx: '50%',
1160
+ cy: '50%',
1161
+ r: '50%',
1162
+ fx: '50%',
1163
+ fy: '50%',
1164
+ };
1165
+ return vue.h(props.gradientType === 'linear' ? 'linearGradient' : 'radialGradient', __assign({ id: 'qr-gradient' }, gradientProps), [
1166
+ vue.h('stop', {
1167
+ offset: '0%',
1168
+ style: { stopColor: props.gradientStartColor },
1169
+ }),
1170
+ vue.h('stop', {
1171
+ offset: '100%',
1172
+ style: { stopColor: props.gradientEndColor },
1173
+ }),
1174
+ ]);
1175
+ };
1176
+ var renderClipPath = function () {
1177
+ var borderRadius = props.imageSettings.borderRadius || 0;
1178
+ if (!props.imageSettings.src)
1179
+ return null;
1180
+ if (borderRadius <= 0)
1181
+ return null;
1182
+ return vue.h('clipPath', { id: 'qr-logo-clip' }, [
1183
+ vue.h('rect', {
1184
+ x: imageProps.x,
1185
+ y: imageProps.y,
1186
+ width: imageProps.width,
1187
+ height: imageProps.height,
1188
+ rx: borderRadius,
1189
+ ry: borderRadius,
1190
+ }),
1191
+ ]);
1192
+ };
1074
1193
  generate();
1075
- vue.onUpdated(generate);
1194
+ vue.watch(props, generate, { deep: true });
1076
1195
  return function () { return vue.h('svg', {
1077
1196
  width: props.size,
1078
1197
  height: props.size,
@@ -1080,12 +1199,17 @@ var QrcodeSvg = vue.defineComponent({
1080
1199
  xmlns: 'http://www.w3.org/2000/svg',
1081
1200
  viewBox: "0 0 ".concat(numCells.value, " ").concat(numCells.value),
1082
1201
  }, [
1083
- vue.h('path', {
1202
+ vue.h('defs', {}, [renderGradient(), renderClipPath()]),
1203
+ vue.h('rect', {
1204
+ width: '100%',
1205
+ height: '100%',
1084
1206
  fill: props.background,
1085
- d: "M0,0 h".concat(numCells.value, "v").concat(numCells.value, "H0z"),
1086
1207
  }),
1087
- vue.h('path', { fill: props.foreground, d: fgPath.value }),
1088
- props.imageSettings.src && vue.h('image', __assign({ href: props.imageSettings.src }, imageProps)),
1208
+ vue.h('path', {
1209
+ fill: props.gradient ? 'url(#qr-gradient)' : props.foreground,
1210
+ d: fgPath.value,
1211
+ }),
1212
+ props.imageSettings.src && vue.h('image', __assign(__assign({ href: props.imageSettings.src }, imageProps), (props.imageSettings.borderRadius ? { 'clip-path': 'url(#qr-logo-clip)' } : {}))),
1089
1213
  ]); };
1090
1214
  },
1091
1215
  });
@@ -1096,7 +1220,7 @@ var QrcodeCanvas = vue.defineComponent({
1096
1220
  var canvasEl = vue.ref(null);
1097
1221
  var imageRef = vue.ref(null);
1098
1222
  var generate = function () {
1099
- var value = props.value, _level = props.level, size = props.size, _margin = props.margin, background = props.background, foreground = props.foreground;
1223
+ var value = props.value, _level = props.level, size = props.size, _margin = props.margin, background = props.background, foreground = props.foreground, gradient = props.gradient, gradientType = props.gradientType, gradientStartColor = props.gradientStartColor, gradientEndColor = props.gradientEndColor;
1100
1224
  var margin = _margin >>> 0;
1101
1225
  var level = validErrorCorrectLevel(_level) ? _level : defaultErrorCorrectLevel;
1102
1226
  var canvas = canvasEl.value;
@@ -1124,13 +1248,27 @@ var QrcodeCanvas = vue.defineComponent({
1124
1248
  cells = excavateModules(cells, imageSettings.excavation);
1125
1249
  }
1126
1250
  }
1127
- var devicePixelRatio = window.devicePixelRatio || 1;
1251
+ var devicePixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
1128
1252
  var scale = (size / numCells) * devicePixelRatio;
1129
1253
  canvas.height = canvas.width = size * devicePixelRatio;
1130
1254
  ctx.scale(scale, scale);
1131
1255
  ctx.fillStyle = background;
1132
1256
  ctx.fillRect(0, 0, numCells, numCells);
1133
- ctx.fillStyle = foreground;
1257
+ if (gradient) {
1258
+ var grad = void 0;
1259
+ if (gradientType === 'linear') {
1260
+ grad = ctx.createLinearGradient(0, 0, numCells, numCells);
1261
+ }
1262
+ else {
1263
+ grad = ctx.createRadialGradient(numCells / 2, numCells / 2, 0, numCells / 2, numCells / 2, numCells / 2);
1264
+ }
1265
+ grad.addColorStop(0, gradientStartColor);
1266
+ grad.addColorStop(1, gradientEndColor);
1267
+ ctx.fillStyle = grad;
1268
+ }
1269
+ else {
1270
+ ctx.fillStyle = foreground;
1271
+ }
1134
1272
  if (SUPPORTS_PATH2D) {
1135
1273
  ctx.fill(new Path2D(generatePath(cells, margin)));
1136
1274
  }
@@ -1144,11 +1282,28 @@ var QrcodeCanvas = vue.defineComponent({
1144
1282
  });
1145
1283
  }
1146
1284
  if (showImage) {
1147
- ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1285
+ var borderRadius = props.imageSettings.borderRadius || 0;
1286
+ if (borderRadius > 0) {
1287
+ ctx.save();
1288
+ ctx.beginPath();
1289
+ if (ctx.roundRect) {
1290
+ ctx.roundRect(imageProps.x, imageProps.y, imageProps.width, imageProps.height, borderRadius);
1291
+ }
1292
+ else {
1293
+ // Fallback for browsers without roundRect support
1294
+ ctx.rect(imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1295
+ }
1296
+ ctx.clip();
1297
+ ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1298
+ ctx.restore();
1299
+ }
1300
+ else {
1301
+ ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1302
+ }
1148
1303
  }
1149
1304
  };
1150
1305
  vue.onMounted(generate);
1151
- vue.onUpdated(generate);
1306
+ vue.watch(props, generate, { deep: true });
1152
1307
  var style = ctx.attrs.style;
1153
1308
  return function () { return vue.h(vue.Fragment, [
1154
1309
  vue.h('canvas', __assign(__assign({}, ctx.attrs), { ref: canvasEl, style: __assign(__assign({}, style), { width: "".concat(props.size, "px"), height: "".concat(props.size, "px") }) })),
@@ -1164,8 +1319,20 @@ var QrcodeCanvas = vue.defineComponent({
1164
1319
  var QrcodeVue = vue.defineComponent({
1165
1320
  name: 'Qrcode',
1166
1321
  render: function () {
1167
- var _a = this.$props, renderAs = _a.renderAs, value = _a.value, size = _a.size, margin = _a.margin, level = _a.level, background = _a.background, foreground = _a.foreground, imageSettings = _a.imageSettings;
1168
- return vue.h(renderAs === 'svg' ? QrcodeSvg : QrcodeCanvas, { value: value, size: size, margin: margin, level: level, background: background, foreground: foreground, imageSettings: imageSettings });
1322
+ var _a = this.$props, renderAs = _a.renderAs, value = _a.value, size = _a.size, margin = _a.margin, level = _a.level, background = _a.background, foreground = _a.foreground, imageSettings = _a.imageSettings, gradient = _a.gradient, gradientType = _a.gradientType, gradientStartColor = _a.gradientStartColor, gradientEndColor = _a.gradientEndColor;
1323
+ return vue.h(renderAs === 'svg' ? QrcodeSvg : QrcodeCanvas, {
1324
+ value: value,
1325
+ size: size,
1326
+ margin: margin,
1327
+ level: level,
1328
+ background: background,
1329
+ foreground: foreground,
1330
+ imageSettings: imageSettings,
1331
+ gradient: gradient,
1332
+ gradientType: gradientType,
1333
+ gradientStartColor: gradientStartColor,
1334
+ gradientEndColor: gradientEndColor,
1335
+ });
1169
1336
  },
1170
1337
  props: QRCodeVueProps,
1171
1338
  });