Function: strokes-renormalize-to-grid

strokes-renormalize-to-grid is a byte-compiled function defined in strokes.el.gz.

Signature

(strokes-renormalize-to-grid POSITIONS &optional GRID-RESOLUTION)

Documentation

Map POSITIONS to a new grid whose dimensions are based on GRID-RESOLUTION.

POSITIONS is a list of positions and stroke-lifts. 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
;;  (cl-loop for element on entries
;;        nconc (if (not (equal (car el) (cadr el)))
;;                  (list (car el)))))
;; yet another (orig) way of doing it...
;;  (if entries
;;      (let* ((current (car entries))
;;	     (rest (cdr entries))
;;	     (non-redundant-list (list current))
;;	     (next nil))
;;	(while rest
;;	  (setq next (car rest))
;;	  (if (equal current next)
;;	      (setq rest (cdr rest))
;;	    (setq non-redundant-list (cons next non-redundant-list)
;;		  current next
;;		  rest (cdr rest))))
;;	(nreverse non-redundant-list))
;;    nil))

(defun strokes-renormalize-to-grid (positions &optional grid-resolution)
  "Map POSITIONS to a new grid whose dimensions are based on GRID-RESOLUTION.
POSITIONS is a list of positions and stroke-lifts.
Optional GRID-RESOLUTION may be used in place of `strokes-grid-resolution'.
The grid is a square whose dimension is [0,GRID-RESOLUTION)."
  (or grid-resolution (setq grid-resolution strokes-grid-resolution))
  (let ((stroke-extent (strokes-get-stroke-extent positions)))
    (mapcar (lambda (pos)
              (strokes-get-grid-position stroke-extent pos grid-resolution))
	    positions)))