// FILE: drawing.cpp // #include "drawing.h" // render the list of figures onto the canvas // by drawing them and saving C as depths are jumped // void drawing::render(drawable_list& L, canvas& C) { L.sort(); // sort figures by depth and order list_iterator I = L.first(); int prev_depth = 0; // last layer if (I.has_more_elements()) { // get depth of first figure prev_depth = (*I)->get_depth(); } while(I.has_more_elements()) { if ((*I)->get_depth() != prev_depth) { // jumping layers!, save canvas C.save_canvas(); prev_depth = (*I)->get_depth(); } // draw figure (*I)->draw(C); I++; } }