Fix drawing target bug and add dimension checking to avoid errors

The previous version condidered incorrectly the position of the target
as the corner instead of the center. Now the coordinates are converted
from center and dimensions to upper left corner and dimensions.

The dimensions of the target are also checked to avoid trying to draw
the dummy target, whose dimensions and position are (-1, -1), and
therefore results in a weird thing being drawn.