fixed windowToCanvas function