Permalink
Browse files

-ps can now take #f or a file-path. If it's passed #f, it prints outp…

…ut to screen instead of to a file
  • Loading branch information...
ingram
ingram committed Jun 25, 2010
1 parent 614ccff commit e75d5f9e63b40b6007f673d3d779b626ada1f8b7
Showing with 19 additions and 11 deletions.
  1. +11 −2 psPrelim.ss
  2. +8 −9 syntax.ss
View
@@ -21,6 +21,10 @@
(path (moveto (car pts))
(apply string-append (map lineto (cdr pts)))))
+(define (curve-shape pts)
+ (path (moveto (car pts))
+ (apply string-append (map curveto(cdr pts)))))
+
(define (rounded-rect pt width height radius)
(let* ((rad (cond ((number? radius) (build-list 4 (lambda (n) radius)))
((= 2 (length radius)) (list (cadr radius) (car radius) (car radius) (cadr radius)))
@@ -47,8 +51,13 @@
(define (circle pt radius)
(path (arc pt radius 0 360)))
-;; (ps (0 0 612 792)
-;; (page (stroke (circle '(200 . 300) 100)))
+;; (ps #f (0 0 612 792)
+;; (page
+;; (translate 500 500)
+;; (for 0 10 360
+;; (scale 1.1 1.1)
+;; (with (rotate)
+;; (stroke (circle '(200 . 300) 100)))))
;; (page (stroke (circle '(150 . 50) 150)))
;; (page (stroke (circle '(50 . 0) 200))))
View
@@ -3,22 +3,21 @@
(define (page . body)
(lambda (page-num page-total b1 b2 b3 b4)
- (string-append (format "%%Page: ~a ~a~n%%BeginPageSetup~n%%PageBoundingBox: ~a ~a ~a ~a~n%%EndPageSetup~n~n"
+ (string-append (format "%%Page: ~a ~a~n%%BeginPageSetup~n%%PageBoundingBox: ~a ~a ~a ~a~n%%EndPageSetup~n"
page-num page-total b1 b2 b3 b4)
(apply string-append body)
"showpage\n\n")))
(define-macro (ps filename bounding-box . pages)
(define (apply-page page num)
`(,page ,num ,(length pages) ,@bounding-box))
- `(display-to-file
- (apply string-append
- (cons (format "%!PS-Adobe-3.0~n%%Pages: ~a~n%%BoundingBox: ~a ~a ~a ~a~n%%DocumentData: Clean7Bit~n%%LanguageLevel: 2~n~n"
- ,(length pages) ,@bounding-box)
- (list ,@(map apply-page
- pages
- (build-list (length pages) (lambda (n) (+ 1 n)))))))
- ,(build-path filename) #:mode 'text #:exists 'replace))
+ (let ((contents `(string-append
+ (format "%!PS-Adobe-3.0~n%%Pages: ~a~n%%BoundingBox: ~a ~a ~a ~a~n%%DocumentData: Clean7Bit~n%%LanguageLevel: 2~n~n"
+ ,(length pages) ,@bounding-box)
+ ,@(map apply-page pages (build-list (length pages) (lambda (n) (+ 1 n)))))))
+ (if filename
+ `(display-to-file ,contents ,(build-path filename) #:mode 'text #:exists 'replace)
+ `(printf ,contents))))
(define-macro (def-pt-op name op)
`(define (,name pt term)

0 comments on commit e75d5f9

Please sign in to comment.