added windowToCanvas function