central function for canvas