refactor for testing and adapt for rendering with other forms diff from rectangles