|
63 | 63 | this.cH = null; // change hook |
64 | 64 | this.eH = null; // cancel hook |
65 | 65 | this.rH = null; // release hook |
| 66 | + this.scale = 1; // scale factor |
66 | 67 |
|
67 | 68 | this.run = function () { |
68 | 69 | var cf = function (e, conf) { |
|
166 | 167 | this.o.height + 'px;"></div>')) |
167 | 168 | .before(this.$c); |
168 | 169 |
|
| 170 | + this.scale = (window.devicePixelRatio || 1) / |
| 171 | + ( |
| 172 | + this.c.webkitBackingStorePixelRatio || |
| 173 | + this.c.mozBackingStorePixelRatio || |
| 174 | + this.c.msBackingStorePixelRatio || |
| 175 | + this.c.oBackingStorePixelRatio || |
| 176 | + this.c.backingStorePixelRatio || 1 |
| 177 | + ); |
| 178 | + if (this.scale !== 1) { |
| 179 | + this.$c[0].width = this.$c[0].width * this.scale; |
| 180 | + this.$c[0].height = this.$c[0].height * this.scale; |
| 181 | + this.$c.width(this.o.width); |
| 182 | + this.$c.height(this.o.height); |
| 183 | + } |
| 184 | + |
169 | 185 | if (this.v instanceof Object) { |
170 | 186 | this.cv = {}; |
171 | 187 | this.copy(this.v, this.cv); |
|
196 | 212 | var d = true, |
197 | 213 | c = document.createElement('canvas'); |
198 | 214 |
|
199 | | - c.width = s.o.width; |
200 | | - c.height = s.o.height; |
| 215 | + c.width = s.o.width * s.scale; |
| 216 | + c.height = s.o.height * s.scale; |
| 217 | + |
201 | 218 | s.g = c.getContext('2d'); |
202 | 219 |
|
203 | 220 | s.clear(); |
|
551 | 568 | this.$.val(this.v); |
552 | 569 | this.w2 = this.o.width / 2; |
553 | 570 | this.cursorExt = this.o.cursor / 100; |
554 | | - this.xy = this.w2; |
| 571 | + this.xy = this.w2 * this.scale; |
555 | 572 | this.lineWidth = this.xy * this.o.thickness; |
556 | 573 | this.lineCap = this.o.lineCap; |
557 | 574 | this.radius = this.xy - this.lineWidth / 2; |
|
0 commit comments