Step 1:
Essentially to make the blue pixel teleport to the opposite borders upong detecting boundries collision, we simply detect when the pixel reaches, say the right most border which is x = 800, then we simple move (teleport) the location of the pixel to x = 0.
So an rough example of the code would be:
if (pixel.x > 800) {
pixel.x = 0;
}
if (pixel.y < 0) {
pixel.y = 600;
}
Exercise
Do teleportation for all sides of the map.