Porting drawRectangle and other stuffs.