summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-04-06 14:50:56 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-04-06 14:50:56 +0200
commit1081365a7137f5e3721798c24f3b9ef847c45d64 (patch)
tree2fa731e24f49f9afd8e88f5e0f914fb6dd64750c
parentc0e6f395d4241b1622c6b44ed2de3636ddab8cb9 (diff)
Add pict-rotation.
-rw-r--r--pict.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/pict.scm b/pict.scm
index 2fa0352..98e0237 100644
--- a/pict.scm
+++ b/pict.scm
@@ -31,6 +31,7 @@
pict-sxml
pict-width
pict-height
+ pict-rotation
;; modifiers
fill
@@ -203,6 +204,13 @@ does not exist it is added with PROC applied to #F."
items))
((_ . items) items))))))
+(define (rotation->values str)
+ "Returns a list of three rotation values by converting the rotation
+string STR."
+ (if str
+ (map string->number (string-split str #\space))
+ (list 0 0 0)))
+
(define (style-string->list styles)
"Split the styles string into a list of lists from keys to values."
(map (cut string-split <> #\:)
@@ -609,6 +617,16 @@ of the SVG of PICT or #F."
"Return the width of PICT."
(pict-attr 'width pict))
+(define (pict-rotation pict)
+ "Return the rotation of PICT."
+ (let ((m (assoc-ref (transform-string->list
+ (or (pict-attr 'transform pict #:path '(g)) ""))
+ "rotate")))
+ (or (and (pair? m)
+ (and=> (first m)
+ (lambda (m) (first (rotation->values m)))))
+ 0)))
+
(define (append-align xalign yalign picts)
"Append PICTS and align them vertically to the top, center, bottom,
or spread by an offset according to the symbol YALIGN and horizontally