all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* can someone help me with the image elisp API
@ 2015-12-07 15:25 Jim Newton
  2015-12-08  7:23 ` Alexis
  2015-12-08  9:30 ` Andy Moreton
  0 siblings, 2 replies; 3+ messages in thread
From: Jim Newton @ 2015-12-07 15:25 UTC (permalink / raw)
  To: help-gnu-emacs

I've opened an image (a .png) file in an emacs buffer.
I'd like to be able to click in the image with the RMB (or any good mouse event),
and somehow relate the point the user clicked to the 
coordinates in the image.

\x10For example, this elisp function gets the x-y position.  Suppose it is (609 . 41)
I want to know if that is in the box within the image coordinates
 (( 447.32 199.28) ( 449.7426 199.9871))

I need of course to consider that the user might have scrolled or panned or zoomed
within the image before calling the class-graph-from-click function.

(defun class-graph-from-click (event)
  (interactive "e")
  (let ((position (event-start event)))
    (posn-x-y position) ;; this is the x-y where the mouse was clicked-down
    (message "xy=%s" (posn-x-y position))))







^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: can someone help me with the image elisp API
  2015-12-07 15:25 can someone help me with the image elisp API Jim Newton
@ 2015-12-08  7:23 ` Alexis
  2015-12-08  9:30 ` Andy Moreton
  1 sibling, 0 replies; 3+ messages in thread
From: Alexis @ 2015-12-08  7:23 UTC (permalink / raw)
  To: Jim Newton; +Cc: help-gnu-emacs


Jim Newton <jimka.issy@gmail.com> writes:

> I've opened an image (a .png) file in an emacs buffer.  I'd like 
> to be able to click in the image with the RMB (or any good mouse 
> event), and somehow relate the point the user clicked to the 
> coordinates in the image.
>
> For example, this elisp function gets the x-y position.  Suppose 
> it is (609 . 41) I want to know if that is in the box within the 
> image coordinates 
>  (( 447.32 199.28) ( 449.7426 199.9871))

Perhaps the :map property of the image descriptor might be of use?

https://www.gnu.org/software/emacs/manual/html_node/elisp/Image-Descriptors.html


Alexis.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: can someone help me with the image elisp API
  2015-12-07 15:25 can someone help me with the image elisp API Jim Newton
  2015-12-08  7:23 ` Alexis
@ 2015-12-08  9:30 ` Andy Moreton
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Moreton @ 2015-12-08  9:30 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon 07 Dec 2015, Jim Newton wrote:

> I've opened an image (a .png) file in an emacs buffer.
> I'd like to be able to click in the image with the RMB (or any good mouse event),
> and somehow relate the point the user clicked to the 
> coordinates in the image.
>
> For example, this elisp function gets the x-y position.  Suppose it is (609 . 41)
> I want to know if that is in the box within the image coordinates
>  (( 447.32 199.28) ( 449.7426 199.9871))
>
> I need of course to consider that the user might have scrolled or panned or zoomed
> within the image before calling the class-graph-from-click function.
>
> (defun class-graph-from-click (event)
>   (interactive "e")
>   (let ((position (event-start event)))
>     (posn-x-y position) ;; this is the x-y where the mouse was clicked-down
>     (message "xy=%s" (posn-x-y position))))

Have a look at the manual at (info "(elisp) Accessing Mouse") which
shows the utility functions provided for handling mouse position data.
It looks like 'posn-image and 'posn-object-x-y position are what you
need.

    AndyM




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-08  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-07 15:25 can someone help me with the image elisp API Jim Newton
2015-12-08  7:23 ` Alexis
2015-12-08  9:30 ` Andy Moreton

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.