Function: pdf-util-scale
pdf-util-scale is a natively compiled function defined in pdf-util.el.
Signature
(pdf-util-scale LIST-OF-EDGES-OR-POS SCALE &optional ROUNDING-FN)
Documentation
Scale LIST-OF-EDGES-OR-POS by SCALE.
SCALE is a cons (SX . SY), by which edges/positions are scaled.
If ROUNDING-FN is non-nil, it should be a function of one
argument, a real value, returning a rounded
value (e.g. ceiling).
The elements in LIST-OF-EDGES-OR-POS should be either a list
(LEFT TOP RIGHT BOT) or a position (X . Y).
LIST-OF-EDGES-OR-POS may also be a single such element.
Return scaled list of edges if LIST-OF-EDGES-OR-POS was indeed a list, else return the scaled singleton.
Source Code
;; Defined in /nix/store/63h5z2vmzn0mfavcxi2idi23g5xcgkbl-emacs-packages-deps/share/emacs/site-lisp/elpa/pdf-tools-20260102.1101/pdf-util.el
;; * ================================================================== *
;; * Transforming coordinates
;; * ================================================================== *
(defun pdf-util-scale (list-of-edges-or-pos scale &optional rounding-fn)
"Scale LIST-OF-EDGES-OR-POS by SCALE.
SCALE is a cons (SX . SY), by which edges/positions are scaled.
If ROUNDING-FN is non-nil, it should be a function of one
argument, a real value, returning a rounded
value (e.g. `ceiling').
The elements in LIST-OF-EDGES-OR-POS should be either a list
\(LEFT TOP RIGHT BOT\) or a position \(X . Y\).
LIST-OF-EDGES-OR-POS may also be a single such element.
Return scaled list of edges if LIST-OF-EDGES-OR-POS was indeed a list,
else return the scaled singleton."
(let ((have-list-p (listp (car list-of-edges-or-pos))))
(unless have-list-p
(setq list-of-edges-or-pos (list list-of-edges-or-pos)))
(let* ((sx (car scale))
(sy (cdr scale))
(result
(mapcar
(lambda (edges)
(cond
((consp (cdr edges))
(let ((e (list (* (nth 0 edges) sx)
(* (nth 1 edges) sy)
(* (nth 2 edges) sx)
(* (nth 3 edges) sy))))
(if rounding-fn
(mapcar rounding-fn e)
e)))
(rounding-fn
(cons (funcall rounding-fn (* (car edges) sx))
(funcall rounding-fn (* (cdr edges) sy))))
(t
(cons (* (car edges) sx)
(* (cdr edges) sy)))))
list-of-edges-or-pos)))
(if have-list-p
result
(car result)))))