summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-04-10 18:40:21 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-04-10 18:40:21 +0200
commit860145884e4f883f01948579eee43e17b006924a (patch)
treeaa120774ba9646ba28bf12621d1753ba663305f9
parent61d5199b483e9da107d2ed940f95749897b646da (diff)
Add pin-over and pin-under.
-rw-r--r--pict.scm33
1 files changed, 33 insertions, 0 deletions
diff --git a/pict.scm b/pict.scm
index fdf9bbd..63cd1d9 100644
--- a/pict.scm
+++ b/pict.scm
@@ -89,6 +89,9 @@
rc-superimpose
rb-superimpose
+ pin-over
+ pin-under
+
;; colors
rgb
colors))
@@ -800,6 +803,36 @@ bottom."
"Stack the given PICTS and align them right and at the bottom."
(append-align 'right 'bottom picts))
+(define (pin-over base dx dy pict)
+ "Create a pict with the same dimensions as BASE, but with PICT
+placed on top. PICT is offset from the top left corner of BASE by DX
+and DY."
+ (make-pict
+ `(svg (@ (height ,(pict-height base))
+ (width ,(pict-width base))
+ (class "pinned")
+ (x 0)
+ (y 0))
+ ,(pict-sxml base)
+ ,((compose (attribute-modifier 'y (const dy))
+ (attribute-modifier 'x (const dx)))
+ (pict-sxml pict)))))
+
+(define (pin-under base dx dy pict)
+ "Create a pict with the same dimensions as BASE, but with PICT
+placed underneath. PICT is offset from the top left corner of BASE by
+DX and DY."
+ (make-pict
+ `(svg (@ (height ,(pict-height base))
+ (width ,(pict-width base))
+ (class "pinned")
+ (x 0)
+ (y 0))
+ ,((compose (attribute-modifier 'y (const dy))
+ (attribute-modifier 'x (const dx)))
+ (pict-sxml pict))
+ ,(pict-sxml base))))
+
;;; Colors