Line drawing function and demo program