summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-04-09 23:08:49 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-04-09 23:08:49 +0200
commitf8e532f5b43496d1d2862fcd8ea4d733836768fb (patch)
treeefcb8f68701968836d456ab7887227c0669e0094
parentdd9eedeaedb8f80e504ce851ffb2a8e7e838c936 (diff)
Add hline and vline.
-rw-r--r--pict.scm35
1 files changed, 27 insertions, 8 deletions
diff --git a/pict.scm b/pict.scm
index 86ee005..3a84476 100644
--- a/pict.scm
+++ b/pict.scm
@@ -56,6 +56,8 @@
rectangle
;; other graphics
+ vline
+ hline
disk
filled-ellipse
filled-rectangle
@@ -417,18 +419,19 @@ strings that are built from the list of attributes LST."
;;; height, and the coordinates.
(define* (line x1 y1 x2 y2
+ #:optional (maxw 0) (maxh 0)
#:key
(color "black")
(stroke-width 1))
(make-pict
- `(svg (@ (width ,(let ((new-width (+ (min x1 x2)
- (abs (- x2 x1)))))
- (if (zero? new-width)
- stroke-width new-width)))
- (height ,(let ((new-height (+ (min y1 y2)
- (abs (- y2 y1)))))
- (if (zero? new-height)
- stroke-width new-height)))
+ `(svg (@ (width ,(max maxw (let ((new-width (+ (min x1 x2)
+ (abs (- x2 x1)))))
+ (if (zero? new-width)
+ stroke-width new-width))))
+ (height ,(max maxh (let ((new-height (+ (min y1 y2)
+ (abs (- y2 y1)))))
+ (if (zero? new-height)
+ stroke-width new-height))))
(x 0)
(y 0))
(line (@ (x1 ,x1)
@@ -440,6 +443,22 @@ strings that are built from the list of attributes LST."
("stroke-width"
,(number->string stroke-width))))))))))
+(define* (hline w h
+ #:key
+ (color "black")
+ (stroke-width 1))
+ (let ((vcenter (exact->inexact (/ h 2))))
+ (line 0 vcenter w vcenter w h
+ #:color color #:stroke-width stroke-width)))
+
+(define* (vline w h
+ #:key
+ (color "black")
+ (stroke-width 1))
+ (let ((hcenter (exact->inexact (/ w 2))))
+ (line hcenter 0 hcenter h w h
+ #:color color #:stroke-width stroke-width)))
+
(define* (polyline points
#:key
(color "black")