demos/bp/public/editor-compiled.js
// Draw a path around the specified blob edge. The edge should be a Set3 of (x,y,dir).
Draw a path around the specified blob edge. The edge should be a Set3 of (x,y,dir).
Draw a path around the specified blob edge . The edge should be a Set3 of ( x y dir ) .
__old_pathAroundEdge(ctx, edge, border, pos) {
    const sx = pos ? pos.sx : 0,
      sy = pos ? pos.sy : 0;
    const lineTo = (x, y, dir, em, first) => {
      var ex = dir === UP || dir === RIGHT ? x+1 : x;
      var ey = dir === RIGHT || dir === DOWN ? y+1 : y;
      ex += sx; ey += sy; 
      var {px, py} = this.view.worldToScreen(ex, ey);
      const {dx, dy} = DIRS[dir];
      px += border * (-dx - dy * em);
      py += border * (-dy + dx * em);
      if (first) {
        ctx.moveTo(px, py);
      } else {
        ctx.lineTo(px, py);
      }
    };
    const visited = new Set3;
    ctx.beginPath();
    edge.forEach((x, y, dir) => {
      if (visited.has(x, y, dir)) return;
      var first = true; 
      while (!visited.has(x, y, dir)) {
        visited.add(x, y, dir);
        const {dx, dy} = DIRS[dir];
        var x2, y2, dir2;
        if (edge.has(x2=x+dx-dy, y2=y+dy+dx, dir2=(dir+3)%4) && 
            !edge.has(x, y, (dir + 1) % 4)) { 
          lineTo(x, y, dir, 1, first);
          x = x2; y = y2; dir = dir2;
          first = false;
        } else if (edge.has((x2=x-dy), (y2=y+dx), dir)) {
          x = x2; y = y2;
        } else {
          lineTo(x, y, dir, -1, first);
          dir = (dir+1) % 4;
          first = false;
        }
      }
      ctx.closePath();
    });
  }
__old_pathAroundEdge ( ctx , edge , border , pos ) { const sx = pos ? pos . sx : 0 , sy = pos ? pos . sy : 0 ; const lineTo = ( x , y , dir , em , first ) => { var ex = dir === UP || dir === RIGHT ? x + 1 : x ; var ey = dir === RIGHT || dir === DOWN ? y + 1 : y ; ex += sx ; ey += sy ; var { px , py } = this . view . worldToScreen ( ex , ey ) ; const { dx , dy } = DIRS [ dir ] ; px += border * ( - dx - dy * em ) ; py += border * ( - dy + dx * em ) ; if ( first ) { ctx . moveTo ( px , py ) ; } else { ctx . lineTo ( px , py ) ; } } ; const visited = new Set3 ; ctx . beginPath ( ) ; edge . forEach ( ( x , y , dir ) => { if ( visited . has ( x , y , dir ) ) return ; var first = true ; while ( ! visited . has ( x , y , dir ) ) { visited . add ( x , y , dir ) ; const { dx , dy } = DIRS [ dir ] ; var x2 , y2 , dir2 ; if ( edge . has ( x2 = x + dx - dy , y2 = y + dy + dx , dir2 = ( dir + 3 ) % 4 ) && ! edge . has ( x , y , ( dir + 1 ) % 4 ) ) { lineTo ( x , y , dir , 1 , first ) ; x = x2 ; y = y2 ; dir = dir2 ; first = false ; } else if ( edge . has ( ( x2 = x - dy ) , ( y2 = y + dx ) , dir ) ) { x = x2 ; y = y2 ; } else { lineTo ( x , y , dir , - 1 , first ) ; dir = ( dir + 1 ) % 4 ; first = false ; } } ctx . closePath ( ) ; } ) ; }
Draw a path around the specified blob edge.
Draw a path around the specified blob edge .
// Ok, now for the actual shuttles themselves // Move to the right of the edge. //var dx, dy, ex, ey, px, py, ref2, ref3; // transform by shuttle state x,y // Come in from the edge // I can't simply draw from the first edge because the shuttle might have // holes (and hence multiple continuous edges). // Using pushEdges because I want to draw the outline around just the // solid shuttle cells. // For the first point we need to call moveTo() not lineTo(). // up-right // fix pincy corners // Curves in _| // straight __ // curves down ^| // We could check for it, but there's no point.