Rewrote draw_sdf.r function.