# Get Image Position in Image Editor for drawing lines with bgl

I am trying to draw some guide-lines on top of my image in my image-view using bgl.

But when I draw the coordinates of my shape/line is relative to the screen/view when I actually want what I draw to always be on top of my image in the image-view.

Is there any way to extract the image position to transform my shape to always be on my image or is there any other way to do this?

So I solved this, it appears that the image editor is also like a 3d coordinate system. So I followed a tut for 3D and then just changed the view to SpaceImageEditor and instead of drawing on 'POST_PIXEL' I drew to 'POST_VIEW'. Code:

def __init__(self):
self.draw_handle = None
self.draw_event = None

self.widgets = []

def invoke(self, context, event):

self.create_batch()

args = (self, context)
self.register_handlers(args, context)

return {'RUNNING_MODAL'}

def register_handlers(self, args, context):

def unregister_handlers(self, context):
context.window_manager.event_timer_remove(self.draw_event)

bpy.types.SpaceImageEditor.draw_handler_remove(self.draw_handle, 'WINDOW')

self.draw_handle = None
self.draw_event = None

def modal(self, context, event):
if context.area:
context.area.tag_redraw()

if event.type in {'ESC'}:
self.unregister_handlers(context)
return {'CANCELLED'}

return {'PASS_THROUGH'}

def finish(self):
self.unregister_handlers(context)
return {'FINISHED'}

def create_batch(self):

vertices = [(0, 0.5, 0), (1, 0.5, 0)]