Get graphics context from extension

Could you please write how you would use this in your extension and how the end user would end up using it? The simplest example.