// the color of a pipe boundary is (84, 56, 72) // apparently red = 84 is unique anywhere else on canvas for (var x = 0; x < data.width; x++) { var red = data.data[x * 4]; if (red != 84) { continue } console.log("pipe x = ", x); for (var y = 0; y < data.height; y++) { var red2 = data.data[(x + y * data.width) * 4]; if (red2 == 84) { console.log("pipe y = ", y); continue } break } }