File: nonrenderer.rkt

package info (click to toggle)
racket 7.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 125,432 kB
  • sloc: ansic: 258,980; pascal: 59,975; sh: 33,650; asm: 13,558; lisp: 7,124; makefile: 3,329; cpp: 2,889; exp: 499; python: 274; xml: 11
file content (65 lines) | stat: -rw-r--r-- 3,233 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#lang typed/racket/base

(require racket/list
         "type-doc.rkt"
         "math.rkt"
         "ticks.rkt"
         "plot-element.rkt"
         "utils.rkt")

(provide (all-defined-out))

(struct nonrenderer plot-element () #:transparent)

(: x-ticks-fun (-> (Listof tick) Boolean Ticks-Fun))
(define ((x-ticks-fun ts far?) r)
  (let-values ([(ts far-ts)  (if far? (values empty ts) (values ts empty))])
    (cond [(= (vector-length r) 2)  (list ts far-ts empty empty)]
          [(= (vector-length r) 3)  (list ts far-ts empty empty empty empty)]
          [else  (raise-argument-error 'x-ticks-fun "vector of length 2 or 3" r)])))

(: y-ticks-fun (-> (Listof tick) Boolean Ticks-Fun))
(define ((y-ticks-fun ts far?) r)
  (let-values ([(ts far-ts)  (if far? (values empty ts) (values ts empty))])
    (cond [(= (vector-length r) 2)  (list empty empty ts far-ts)]
          [(= (vector-length r) 3)  (list empty empty ts far-ts empty empty)]
          [else  (raise-argument-error 'y-ticks-fun "vector of length 2 or 3" r)])))

(: z-ticks-fun (-> (Listof tick) Boolean Ticks-Fun))
(define ((z-ticks-fun ts far?) r)
  (let-values ([(ts far-ts)  (if far? (values empty ts) (values ts empty))])
    (cond [(= (vector-length r) 3)  (list empty empty empty empty ts far-ts)]
          [else  (raise-argument-error 'z-ticks-fun "vector of length 2 or 3" r)])))

(:: x-ticks (->* [(Listof tick)] [#:far? Boolean] nonrenderer))
(define (x-ticks ts #:far? [far? #f])
  (nonrenderer #f #f (x-ticks-fun ts far?)))

(:: y-ticks (->* [(Listof tick)] [#:far? Boolean] nonrenderer))
(define (y-ticks ts #:far? [far? #f])
  (nonrenderer #f #f (y-ticks-fun ts far?)))

(:: z-ticks (->* [(Listof tick)] [#:far? Boolean] nonrenderer))
(define (z-ticks ts #:far? [far? #f])
  (nonrenderer #f #f (z-ticks-fun ts far?)))

(:: invisible-rect (-> (U Real #f) (U Real #f) (U Real #f) (U Real #f) nonrenderer))
(define (invisible-rect x-min x-max y-min y-max)
  (define fail (make-raise-argument-error 'invisible-rect x-min x-max y-min y-max))
  (cond [(and x-min (not (rational? x-min)))  (fail "#f or rational" 0)]
        [(and x-max (not (rational? x-max)))  (fail "#f or rational" 1)]
        [(and y-min (not (rational? y-min)))  (fail "#f or rational" 2)]
        [(and y-max (not (rational? y-max)))  (fail "#f or rational" 3)]
        [else  (nonrenderer (vector (ivl x-min x-max) (ivl y-min y-max)) #f #f)]))

(:: invisible-rect3d (-> (U Real #f) (U Real #f) (U Real #f) (U Real #f) (U Real #f) (U Real #f)
                         nonrenderer))
(define (invisible-rect3d x-min x-max y-min y-max z-min z-max)
  (define fail (make-raise-argument-error 'invisible-rect3d x-min x-max y-min y-max z-min z-max))
  (cond [(and x-min (not (rational? x-min)))  (fail "#f or rational" 0)]
        [(and x-max (not (rational? x-max)))  (fail "#f or rational" 1)]
        [(and y-min (not (rational? y-min)))  (fail "#f or rational" 2)]
        [(and y-max (not (rational? y-max)))  (fail "#f or rational" 3)]
        [(and z-min (not (rational? z-min)))  (fail "#f or rational" 4)]
        [(and z-max (not (rational? z-max)))  (fail "#f or rational" 5)]
        [else  (nonrenderer (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f #f)]))