Function: pdf-util-edges-transform
pdf-util-edges-transform is a natively compiled function defined in
pdf-util.el.
Signature
(pdf-util-edges-transform REGION ELTS &optional TO-REGION-P)
Documentation
Translate ELTS according to REGION.
ELTS may be one edges list or a position or a list thereof. Translate each from region coordinates to (0 0 1 1) or the opposite, if TO-REGION-P is non-nil. All coordinates should be relative.
Returns the translated list of elements or the single one depending on the input.
Source Code
;; Defined in /nix/store/63h5z2vmzn0mfavcxi2idi23g5xcgkbl-emacs-packages-deps/share/emacs/site-lisp/elpa/pdf-tools-20260102.1101/pdf-util.el
(defun pdf-util-edges-transform (region elts &optional to-region-p)
"Translate ELTS according to REGION.
ELTS may be one edges list or a position or a list thereof.
Translate each from region coordinates to (0 0 1 1) or the
opposite, if TO-REGION-P is non-nil. All coordinates should be
relative.
Returns the translated list of elements or the single one
depending on the input."
(when elts
(let ((have-list-p (consp (car-safe elts))))
(unless have-list-p
(setq elts (list elts)))
(let ((result
(if (null region)
elts
(mapcar (lambda (edges)
(let ((have-pos-p (numberp (cdr edges))))
(when have-pos-p
(setq edges (list (car edges) (cdr edges)
(car edges) (cdr edges))))
(pdf-util-with-edges (edges region)
(let ((newedges
(mapcar (lambda (n)
(min 1.0 (max 0.0 n)))
(if to-region-p
`(,(/ (- edges-left region-left)
region-width)
,(/ (- edges-top region-top)
region-height)
,(/ (- edges-right region-left)
region-width)
,(/ (- edges-bot region-top)
region-height))
`(,(+ (* edges-left region-width)
region-left)
,(+ (* edges-top region-height)
region-top)
,(+ (* edges-right region-width)
region-left)
,(+ (* edges-bot region-height)
region-top))))))
(if have-pos-p
(cons (car newedges) (cadr newedges))
newedges)))))
elts))))
(if have-list-p
result
(car result))))))