(module (s9fes char-canvas shape cross) (;export cross-+-plotter cross-x-plotter) (import scheme utf8) (import (chicken base)) (import (chicken fixnum)) (import (chicken type)) (import (s9fes char-canvas)) (include-relative "s9fes.char-canvas.types") (define-type shape-point-plotter (canvas #!optional fixnum fixnum -> void)) (: cross-+-plotter (fixnum #!optional fixnum (or false char plotter-configuration) -> shape-point-plotter)) (: cross-x-plotter (fixnum #!optional fixnum (or false char plotter-configuration) -> shape-point-plotter)) ;; (define (cross-+-plotter wd #!optional (ht wd) (cfg (current-plotter-char))) ;left & right bars (let* ((cfg (validate-plotter-configuration 'cross-+-plotter cfg 2)) (mx (- wd 1)) (my (- ht 1)) (c1 (car cfg)) (c2 (cadr cfg)) (wd2 (/ wd 2)) (ht2 (/ ht 2)) ) (lambda (cv #!optional (x0 0) (y0 0)) (let ((xm (+ x0 wd2)) (ym (+ y0 ht2))) (when c1 (canvas-plot-line cv x0 ym (+ x0 mx) ym c1)) (when c2 (canvas-plot-line cv xm (+ y0 my) xm y0 c2)) ) ) ) ) (define (cross-x-plotter wd #!optional (ht wd) (cfg (current-plotter-char))) ;left & right bars (let* ((cfg (validate-plotter-configuration 'cross-+-plotter cfg 2)) (mx (- wd 1)) (my (- ht 1)) (c1 (car cfg)) (c2 (cadr cfg)) ) (lambda (cv #!optional (x0 0) (y0 0)) (let ((x1 (+ x0 mx)) (y1 (+ y0 my))) (when c1 (canvas-plot-line cv x0 y1 x1 y0 c1)) (when c2 (canvas-plot-line cv x0 y0 x1 y1 c2)) ) ) ) ) ) ;module (s9fes char-canvas shape cross)