Moving the primitive drawing code to a separate function.
Authored by: debug 2018-11-21
Parent: [r6119]
Child: [r6121]