@@ -461,16 +461,20 @@ class Drawable {
461
461
462
462
const localPosition = getLocalPosition ( this , vec ) ;
463
463
464
- if ( this . useNearest ) {
464
+ // We're not passing in a scale to useNearest, but that's okay because "touching" queries
465
+ // happen at the "native" size anyway.
466
+ if ( this . useNearest ( ) ) {
465
467
return this . skin . isTouchingNearest ( localPosition ) ;
466
468
}
467
469
return this . skin . isTouchingLinear ( localPosition ) ;
468
470
}
469
471
470
472
/**
471
473
* Should the drawable use NEAREST NEIGHBOR or LINEAR INTERPOLATION mode
474
+ * @param {?Array<Number> } scale Optionally, the screen-space scale of the drawable.
475
+ * @return {boolean } True if the drawable should use nearest-neighbor interpolation.
472
476
*/
473
- get useNearest ( ) {
477
+ useNearest ( scale = this . scale ) {
474
478
// Raster skins (bitmaps) should always prefer nearest neighbor
475
479
if ( this . skin . isRaster ) {
476
480
return true ;
@@ -492,8 +496,8 @@ class Drawable {
492
496
}
493
497
494
498
// If the scale of the skin is very close to 100 (0.99999 variance is okay I guess)
495
- if ( Math . abs ( this . scale [ 0 ] ) > 99 && Math . abs ( this . scale [ 0 ] ) < 101 &&
496
- Math . abs ( this . scale [ 1 ] ) > 99 && Math . abs ( this . scale [ 1 ] ) < 101 ) {
499
+ if ( Math . abs ( scale [ 0 ] ) > 99 && Math . abs ( scale [ 0 ] ) < 101 &&
500
+ Math . abs ( scale [ 1 ] ) > 99 && Math . abs ( scale [ 1 ] ) < 101 ) {
497
501
return true ;
498
502
}
499
503
return false ;
@@ -685,7 +689,7 @@ class Drawable {
685
689
}
686
690
const textColor =
687
691
// commenting out to only use nearest for now
688
- // drawable.useNearest ?
692
+ // drawable.useNearest() ?
689
693
drawable . skin . _silhouette . colorAtNearest ( localPosition , dst ) ;
690
694
// : drawable.skin._silhouette.colorAtLinear(localPosition, dst);
691
695
return EffectTransform . transformColor ( drawable , textColor , textColor ) ;
0 commit comments