@@ -126,8 +126,8 @@ class Silhouette {
126
126
colorAtNearest ( vec , dst ) {
127
127
return getColor4b (
128
128
this ,
129
- Math . floor ( vec [ 0 ] * ( this . _width - 1 ) ) ,
130
- Math . floor ( vec [ 1 ] * ( this . _height - 1 ) ) ,
129
+ Math . round ( vec [ 0 ] * this . _width ) ,
130
+ Math . round ( vec [ 1 ] * this . _height ) ,
131
131
dst
132
132
) ;
133
133
}
@@ -140,8 +140,8 @@ class Silhouette {
140
140
* @returns {Uint8ClampedArray } dst
141
141
*/
142
142
colorAtLinear ( vec , dst ) {
143
- const x = vec [ 0 ] * ( this . _width - 1 ) ;
144
- const y = vec [ 1 ] * ( this . _height - 1 ) ;
143
+ const x = vec [ 0 ] * this . _width ;
144
+ const y = vec [ 1 ] * this . _height ;
145
145
146
146
const x1D = x % 1 ;
147
147
const y1D = y % 1 ;
@@ -173,8 +173,8 @@ class Silhouette {
173
173
if ( ! this . _colorData ) return ;
174
174
return getPoint (
175
175
this ,
176
- Math . floor ( vec [ 0 ] * ( this . _width - 1 ) ) ,
177
- Math . floor ( vec [ 1 ] * ( this . _height - 1 ) )
176
+ Math . round ( vec [ 0 ] * this . _width ) ,
177
+ Math . round ( vec [ 1 ] * this . _height )
178
178
) > 0 ;
179
179
}
180
180
@@ -186,8 +186,8 @@ class Silhouette {
186
186
*/
187
187
isTouchingLinear ( vec ) {
188
188
if ( ! this . _colorData ) return ;
189
- const x = Math . floor ( vec [ 0 ] * ( this . _width - 1 ) ) ;
190
- const y = Math . floor ( vec [ 1 ] * ( this . _height - 1 ) ) ;
189
+ const x = Math . round ( vec [ 0 ] * this . _width ) ;
190
+ const y = Math . round ( vec [ 1 ] * this . _height ) ;
191
191
return getPoint ( this , x , y ) > 0 ||
192
192
getPoint ( this , x + 1 , y ) > 0 ||
193
193
getPoint ( this , x , y + 1 ) > 0 ||
0 commit comments