[pygtk] Problems with coordinates in a drawing area control
Jamie Bliss
astronouth7303 at gmail.com
Sat Oct 15 13:04:07 WST 2011
There are several transformation methods: transform(), translate(),
scale(), and rotate(). You need a transformation to go from this
coordinate space:
^
| (Your user space)
|
+-------->
To this:
+-------->
|
| (The actual pixel space)
V
So you need to perform both a flip and a translate.
On Fri, Oct 14, 2011 at 7:05 PM, craf <pyclutter at gmail.com> wrote:
> Hi Jamie
>
> Thank you very much for answering, if you could give me a small
> example,I appreciate it.
>
> I probe with cr.translate(0,-1 * 200), but nothing
>
> Regards
>
> Craf
>>-----Mensaje original-----
>>De: Jamie Bliss <astronouth7303 at gmail.com>
>>Para: craf <pyclutter at gmail.com>
>>Cc: Pygtk <pygtk at daa.com.au>
>>Asunto: Re: [pygtk] Problems with coordinates in a drawing area control
>>F>echa: Fri, 14 Oct 2011 18:32:03 -0400
>
> The X requires no change. Just flip and translate the Y.
>
> On Fri, Oct 14, 2011 at 12:52 PM, craf <pyclutter at gmail.com> wrote:
>> Hi everyone!
>>
>> I'm trying to learn PyCairo, and using the following code, I created a
>> window with a scale of 200 x 200
>>
>>
>> CODE:-------------------------------------
>>
>> #!/usr/bin/python
>>
>> import gtk
>>
>>
>> class Window():
>>
>> def __init__(self):
>>
>> self.window = gtk.Window()
>> self.drwArea = gtk.DrawingArea()
>>
>> self.window.add(self.drwArea)
>> self.window.show_all()
>>
>> # Events-----
>>
>> self.drwArea.add_events(gtk.gdk.POINTER_MOTION_MASK)
>>
>>
>> # Signals-----
>>
>> self.window.connect("destroy", lambda e:gtk.main_quit())
>>
>> self.drwArea.connect("expose-event", expose, self)
>>
>> self.drwArea.connect("motion-notify-event", motion_notify,
>> self)
>>
>>
>> def expose(widget, event, self):
>>
>> cr = widget.window.cairo_create()
>>
>> cr.scale(200,200)
>>
>>
>> def motion_notify(widget, event, self):
>>
>> print "x=%d y=%d" % (event.x, event.y)
>>
>> Window()
>> gtk.main()
>>
>> -CODE:---------------------------------------------------
>>
>> The problem is the coordinate system, leaving the point (0.0) in:
>>
>> ______________________________
>> |(0,0) |
>> | |
>> | |
>> | |
>> | |
>> | |
>> |______________________________|
>>
>> and I want to stay well:
>>
>> _______________________________
>> | |
>> | |
>> | |
>> | |
>> | |
>> | |
>> |(0,0)_________________________|
>>
>>
>> I tested with cr.translate (-200, -200), but does not work.
>>
>>
>> I appreciate any suggestions.
>>
>> Regards.
>>
>> Craf.
>>
>>
>> DATES:
>> Python 2.6.4
>> Ubuntu 9.10
>> Gnome 2.28.0
>>
>> _______________________________________________
>> pygtk mailing list pygtk at daa.com.au
>> http://www.daa.com.au/mailman/listinfo/pygtk
>> Read the PyGTK FAQ: http://faq.pygtk.org/
>>
>
>
>
>
More information about the pygtk
mailing list