|
1 | 1 | /*!
|
2 |
| - * CanvasInput v1.2.1 |
| 2 | + * CanvasInput v1.2.2 |
3 | 3 | * http://goldfirestudios.com/blog/108/CanvasInput-HTML5-Canvas-Text-Input
|
4 | 4 | *
|
5 | 5 | * (c) 2013-2015, James Simpson of GoldFire Studios
|
|
32 | 32 | self._placeHolderColor = o.placeHolderColor || '#bfbebd';
|
33 | 33 | self._fontWeight = o.fontWeight || 'normal';
|
34 | 34 | self._fontStyle = o.fontStyle || 'normal';
|
| 35 | + self._fontShadowColor = o.fontShadowColor || ''; |
| 36 | + self._fontShadowBlur = o.fontShadowBlur || 0; |
| 37 | + self._fontShadowOffsetX = o.fontShadowOffsetX || 0; |
| 38 | + self._fontShadowOffsetY = o.fontShadowOffsetY || 0; |
35 | 39 | self._readonly = o.readonly || false;
|
36 | 40 | self._maxlength = o.maxlength || null;
|
37 | 41 | self._width = o.width || 150;
|
|
356 | 360 | }
|
357 | 361 | },
|
358 | 362 |
|
| 363 | + /** |
| 364 | + * Get/set the font shadow color. |
| 365 | + * @param {String} data Font shadow color. |
| 366 | + * @return {Mixed} CanvasInput or current font shadow color. |
| 367 | + */ |
| 368 | + fontShadowColor: function(data) { |
| 369 | + var self = this; |
| 370 | + |
| 371 | + if (typeof data !== 'undefined') { |
| 372 | + self._fontShadowColor = data; |
| 373 | + |
| 374 | + return self.render(); |
| 375 | + } else { |
| 376 | + return self._fontShadowColor; |
| 377 | + } |
| 378 | + }, |
| 379 | + |
| 380 | + /** |
| 381 | + * Get/set the font shadow blur. |
| 382 | + * @param {String} data Font shadow blur. |
| 383 | + * @return {Mixed} CanvasInput or current font shadow blur. |
| 384 | + */ |
| 385 | + fontShadowBlur: function(data) { |
| 386 | + var self = this; |
| 387 | + |
| 388 | + if (typeof data !== 'undefined') { |
| 389 | + self._fontShadowBlur = data; |
| 390 | + |
| 391 | + return self.render(); |
| 392 | + } else { |
| 393 | + return self._fontShadowBlur; |
| 394 | + } |
| 395 | + }, |
| 396 | + |
| 397 | + /** |
| 398 | + * Get/set the font shadow x-offset. |
| 399 | + * @param {String} data Font shadow x-offset. |
| 400 | + * @return {Mixed} CanvasInput or current font shadow x-offset. |
| 401 | + */ |
| 402 | + fontShadowOffsetX: function(data) { |
| 403 | + var self = this; |
| 404 | + |
| 405 | + if (typeof data !== 'undefined') { |
| 406 | + self._fontShadowOffsetX = data; |
| 407 | + |
| 408 | + return self.render(); |
| 409 | + } else { |
| 410 | + return self._fontShadowOffsetX; |
| 411 | + } |
| 412 | + }, |
| 413 | + |
| 414 | + /** |
| 415 | + * Get/set the font shadow y-offset. |
| 416 | + * @param {String} data Font shadow y-offset. |
| 417 | + * @return {Mixed} CanvasInput or current font shadow y-offset. |
| 418 | + */ |
| 419 | + fontShadowOffsetY: function(data) { |
| 420 | + var self = this; |
| 421 | + |
| 422 | + if (typeof data !== 'undefined') { |
| 423 | + self._fontShadowOffsetY = data; |
| 424 | + |
| 425 | + return self.render(); |
| 426 | + } else { |
| 427 | + return self._fontShadowOffsetY; |
| 428 | + } |
| 429 | + }, |
| 430 | + |
359 | 431 | /**
|
360 | 432 | * Get/set the width of the text box.
|
361 | 433 | * @param {Number} data Width in pixels.
|
|
1040 | 1112 |
|
1041 | 1113 | ctx.fillStyle = (self._value !== '' && self._value !== self._placeHolder) ? self._fontColor : self._placeHolderColor;
|
1042 | 1114 | ctx.font = self._fontStyle + ' ' + self._fontWeight + ' ' + self._fontSize + 'px ' + self._fontFamily;
|
| 1115 | + ctx.shadowColor = self._fontShadowColor; |
| 1116 | + ctx.shadowBlur = self._fontShadowBlur; |
| 1117 | + ctx.shadowOffsetX = self._fontShadowOffsetX; |
| 1118 | + ctx.shadowOffsetY = self._fontShadowOffsetY; |
1043 | 1119 | ctx.textAlign = 'left';
|
1044 | 1120 | ctx.textBaseline = 'middle';
|
1045 | 1121 | ctx.fillText(text, textX, textY);
|
|
0 commit comments