demos/bp/public/editor-compiled.js
// Same as screenToWorld, but also returns which cell in the result.
Same as screenToWorld, but also returns which cell in the result.
Same as screenToWorld but also returns which cell in the result .
screenToWorldCell(px, py, jit) {
    if (px == null) return {tx:null, ty:null};
    px += Math.floor(this.scrollX * this.size);
    py += Math.floor(this.scrollY * this.size);
    const tx_ = px / this.size, ty_ = py / this.size;
    const tx = Math.floor(tx_), ty = Math.floor(ty_);
    const v = jit.get('base', tx, ty);
    if (!v) return {tx, ty, tc:null};
    const offX = tx_ - tx, offY = ty_ - ty;
    const upRight = offX > offY;
    const downRight = offX + offY > 1;
    var tc;
    switch (v) {
      case 'bridge': 
        tc = (upRight !== downRight) ? UP : RIGHT;
        break;
      case 'ribbon': case 'ribbonbridge':
        tc = Math.floor(offY * util.NUMINS);
        break;
      case 'negative': case 'positive':
        tc = upRight ? (downRight ? RIGHT : UP) : (downRight ? DOWN : LEFT);
        break;
      default:
        tc = 0;
    }
    return {tx, ty, tc};
  }
screenToWorldCell ( px , py , jit ) { if ( px == null ) return { tx : null , ty : null } ; px += Math . floor ( this . scrollX * this . size ) ; py += Math . floor ( this . scrollY * this . size ) ; const tx_ = px / this . size , ty_ = py / this . size ; const tx = Math . floor ( tx_ ) , ty = Math . floor ( ty_ ) ; const v = jit . get ( 'base' , tx , ty ) ; if ( ! v ) return { tx , ty , tc : null } ; const offX = tx_ - tx , offY = ty_ - ty ; const upRight = offX > offY ; const downRight = offX + offY > 1 ; var tc ; switch ( v ) { case 'bridge' : tc = ( upRight !== downRight ) ? UP : RIGHT ; break ; case 'ribbon' : case 'ribbonbridge' : tc = Math . floor ( offY * util . NUMINS ) ; break ; case 'negative' : case 'positive' : tc = upRight ? ( downRight ? RIGHT : UP ) : ( downRight ? DOWN : LEFT ) ; break ; default : tc = 0 ; } return { tx , ty , tc } ; }
Same as screenToWorld, but also returns which cell in the result.
Same as screenToWorld but also returns which cell in the result .
// This logic is adapted from screenToWorld above. // There's no cell for solid (null) cells. // The only cells are UP and RIGHT.