()
| 54 | |
| 55 | // TODO Could cache the default icon separately |
| 56 | cacheLockedImage () { |
| 57 | if (this.lockedImageURL) { return this.lockedImageURL } |
| 58 | const canvas = document.createElement('canvas') |
| 59 | const image = new Image() |
| 60 | image.src = this.getImageURL() |
| 61 | const defer = $.Deferred() |
| 62 | image.onload = () => { |
| 63 | canvas.width = image.width |
| 64 | canvas.height = image.height |
| 65 | const context = canvas.getContext('2d') |
| 66 | context.drawImage(image, 0, 0) |
| 67 | let imgData = context.getImageData(0, 0, canvas.width, canvas.height) |
| 68 | imgData = utils.grayscale(imgData) |
| 69 | context.putImageData(imgData, 0, 0) |
| 70 | this.lockedImageURL = canvas.toDataURL() |
| 71 | return defer.resolve(this.lockedImageURL) |
| 72 | } |
| 73 | return defer |
| 74 | } |
| 75 | |
| 76 | getLockedImageURL () { return this.lockedImageURL } |
| 77 |
nothing calls this directly
no test coverage detected