|
141 | 141 | },
|
142 | 142 | // So lines (especially vertical and horizontal) look a) consistent along their length and b) sharp.
|
143 | 143 | pixelSnap: function(position, lineWidth) {
|
144 |
| - if (lineWidth % 2 === 0) { |
| 144 | + // TODO grid lines and bezier lines still (occasionally) wobble. But it's still better than it was. |
| 145 | + |
| 146 | + var dpr = window.devicePixelRatio |
| 147 | + coordinatesPerPixel = 1 / dpr; |
| 148 | + |
| 149 | + // return position - position % window.devicePixelRatio; |
| 150 | + // return position - position % coordinatesPerPixel; |
| 151 | + |
| 152 | + // if (lineWidth % (2 * dpr) === 0) { |
| 153 | + |
| 154 | + // TODO may need to replace the strict comparison with `<= coordinatesPerPixel / 2` (or something |
| 155 | + // like this), that will minimize smudging instead of only removing it when it's strictly divisible. |
| 156 | + // Not only because of truncation error that comes with `dpr !== 1` but because it also makes sense for |
| 157 | + // `dpr === 1`. |
| 158 | + if (lineWidth % (2 * coordinatesPerPixel) === 0) { |
145 | 159 | // Closest pixel edge.
|
146 |
| - return Math.round(position); |
| 160 | + // return Math.round(position); |
| 161 | + |
| 162 | + // TODO It's not the closest, it's round down. |
| 163 | + return position - position % coordinatesPerPixel; |
147 | 164 | } else {
|
148 | 165 | // Closest pixel center.
|
149 |
| - return Math.floor(position) + 0.5; |
| 166 | + // return Math.floor(position) + 0.5; |
| 167 | + return position - position % coordinatesPerPixel + coordinatesPerPixel / 2; |
150 | 168 | }
|
151 | 169 | },
|
152 | 170 | };
|
|
797 | 815 | time = time || nowMillis - (this.delay || 0);
|
798 | 816 |
|
799 | 817 | // Round time down to pixel granularity, so motion appears smoother.
|
800 |
| - time -= time % this.options.millisPerPixel; |
| 818 | + // time -= time % this.options.millisPerPixel; |
| 819 | + // time -= time % (this.options.millisPerPixel / window.devicePixelRatio); |
| 820 | + time -= time % (this.options.millisPerPixel / window.devicePixelRatio); |
801 | 821 |
|
802 | 822 | if (!this.isAnimatingScale) {
|
803 | 823 | // We're not animating. We can use the last render time and the scroll speed to work out whether
|
|
0 commit comments