Function: strokes-get-grid-position
strokes-get-grid-position is a byte-compiled function defined in
strokes.el.gz.
Signature
(strokes-get-grid-position STROKE-EXTENT POSITION &optional GRID-RESOLUTION)
Documentation
Map POSITION to a new grid position.
Do so based on its STROKE-EXTENT and GRID-RESOLUTION.
STROKE-EXTENT is a list ((XMIN . YMIN) (XMAX . YMAX)).
If POSITION is a strokes-lift, then it is itself returned.
Optional GRID-RESOLUTION may be used in place of strokes-grid-resolution.
The grid is a square whose dimension is [0,GRID-RESOLUTION).
Source Code
;; Defined in /usr/src/emacs/lisp/strokes.el.gz
;;(defun global-unset-stroke (stroke); FINISH THIS DEFUN!
;; "delete all strokes matching STROKE from `strokes-global-map',
;; letting the user input
;; the stroke with the mouse"
;; (interactive
;; (list
;; (strokes-read-stroke "Enter the stroke you want to delete...")))
;; (strokes-define-stroke 'strokes-global-map stroke command))
(defun strokes-get-grid-position (stroke-extent position &optional grid-resolution)
"Map POSITION to a new grid position.
Do so based on its STROKE-EXTENT and GRID-RESOLUTION.
STROKE-EXTENT is a list ((XMIN . YMIN) (XMAX . YMAX)).
If POSITION is a `strokes-lift', then it is itself returned.
Optional GRID-RESOLUTION may be used in place of `strokes-grid-resolution'.
The grid is a square whose dimension is [0,GRID-RESOLUTION)."
(cond ((consp position) ; actual pixel location
(let ((grid-resolution (or grid-resolution strokes-grid-resolution))
(x (car position))
(y (cdr position))
(xmin (caar stroke-extent))
(ymin (cdar stroke-extent))
;; the `1+' is there to insure that the
;; formula evaluates correctly at the boundaries
(xmax (1+ (car (cadr stroke-extent))))
(ymax (1+ (cdr (cadr stroke-extent)))))
(cons (floor (* grid-resolution
(/ (float (- x xmin))
(- xmax xmin))))
(floor (* grid-resolution
(/ (float (- y ymin))
(- ymax ymin)))))))
((strokes-lift-p position) ; stroke lift
strokes-lift)))