-
Notifications
You must be signed in to change notification settings - Fork 12
/
plotter-drawing.lisp
761 lines (697 loc) · 33.4 KB
/
plotter-drawing.lisp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
(in-package :plotter)
;; ------------------------------------------
#|
(defun draw-path (port &rest positions)
(gp:draw-polygon port
(mapcan #'append positions)))
|#
;; ------------------------------------------
#|
(defun zip (&rest seqs)
(apply #'map 'list #'list seqs))
(defun staircase (xv yv)
(let ((pairs (zip xv yv)))
(um:foldl
(lambda (ans pair)
(destructuring-bind (x y) pair
(destructuring-bind (xprev yprev &rest _) ans
(declare (ignore _))
(let ((xmid (* 0.5 (+ x xprev))))
(nconc (list x y xmid y xmid yprev) ans)
))))
(first pairs)
(rest pairs)
)))
(defun make-bars (xv yv)
(let ((pairs (zip xv yv)))
(um:foldl
(lambda (ans pair)
(destructuring-bind (x y) pair
(destructuring-bind (xprev &rest _) ans
(declare (ignore _))
(let ((xmid (* 0.5 (+ x xprev))))
(nconc (list x y xmid y) ans)
))))
(first pairs)
(rest pairs)
)))
(defun interleave (&rest seqs)
(mapcan #'nconc (apply #'zip seqs)))
|#
;; -------------------------------------------------------
#|
(defmethod draw-vertical-bars (port (bars <pair-scanner>))
(let* (xprev
yprev
last-x
(wd (* 0.1 (gp:port-width port))) ;; default if only one data point
(wd/2 (* 0.5 wd)))
(with-pairs (bars x y)
(when xprev
(setf wd (abs (- x xprev))
wd/2 (* 0.5 wd))
(unless (= y yprev)
(let ((next-x (+ xprev wd/2))
(prev-x (or last-x
(- xprev wd/2))
))
(gp:draw-rectangle port prev-x 0 (- next-x prev-x) yprev :filled t)
(setf last-x next-x)
)))
(setf xprev x
yprev y))
(when xprev
;; use the last known width
(let ((next-x (+ xprev wd/2))
(prev-x (or last-x
(- xprev wd/2))
))
(gp:draw-rectangle port prev-x 0 (- next-x prev-x) yprev :filled t)
))
))
(defmethod draw-horizontal-bars (port (bars <pair-scanner>))
(let* (xprev
yprev
last-y
(wd (* 0.1 (gp:port-height port))) ;; default if only one data point
(wd/2 (* 0.5 wd)))
(with-pairs (bars x y)
(when yprev
(setf wd (abs (- y yprev))
wd/2 (* 0.5 wd))
(unless (= x xprev)
(let ((next-y (+ yprev wd/2))
(prev-y (or last-y
(- yprev wd/2))
))
(gp:draw-rectangle port 0 prev-y xprev (- next-y prev-y) :filled t)
(setf last-y next-y)
)))
(setf xprev x
yprev y))
(when xprev
;; use the last known width
(let ((next-y (+ yprev wd/2))
(prev-y (or last-y
(- yprev wd/2))
))
(gp:draw-rectangle port 0 prev-y xprev (- next-y prev-y) :filled t)
))
))
|#
;; ----------------------------------------------------------
(defun get-symbol-plotfn (pane symbol-style)
(labels ((draw-symbol (fn)
#-:WIN32
(with-color (pane (or (if (fill-color symbol-style)
(adjust-color pane
(fill-color symbol-style)
(fill-alpha symbol-style)))
#.(color:make-gray 1.0 0.25)))
(funcall fn t))
#+:WIN32
(when (fill-color symbol-style)
(with-color (pane (adjust-color pane
(fill-color symbol-style)
(fill-alpha symbol-style)))
(funcall fn t)))
(gp:with-graphics-state (pane
:thickness (adjust-linewidth (border-thick symbol-style))
:foreground (adjust-color pane
(border-color symbol-style)
(border-alpha symbol-style)))
(funcall fn))))
(ecase (plot-symbol symbol-style)
(:cross (lambda (x y)
(gp:with-graphics-state (pane
:thickness (adjust-linewidth (border-thick symbol-style))
:foreground (adjust-color pane
(border-color symbol-style)
(border-alpha symbol-style)))
(gp:draw-line pane (- x 3) y (+ x 3) y)
(gp:draw-line pane x (- y 3) x (+ y 3))
)))
(:x (lambda (x y)
(gp:with-graphics-state (pane
:thickness (adjust-linewidth (border-thick symbol-style))
:foreground (adjust-color pane
(border-color symbol-style)
(border-alpha symbol-style)))
(gp:draw-line pane (- x 3) (- y 3) (+ x 3) (+ y 3))
(gp:draw-line pane (+ x 3) (- y 3) (- x 3) (+ y 3))
)))
((:circle :sampled-data)
(lambda (x y)
(labels ((draw-circle (&optional filled)
(gp:draw-circle pane
x
#-:WIN32 (- y 0.5)
#+:WIN32 y
3
:filled filled)))
(draw-symbol #'draw-circle)
)))
((:box :square)
(lambda (x y)
(labels ((draw-rectangle (&optional filled)
(gp:draw-rectangle pane (- x 3) (- y 3) 6 6
:filled filled)))
(draw-symbol #'draw-rectangle)
)))
((:triangle :up-triangle)
(lambda (x y)
(labels ((draw-triangle (&optional filled)
(gp:draw-polygon pane
(list (- x 3) (+ y 3)
x (- y 4)
(+ x 3) (+ y 3))
:closed t
:filled filled)))
(draw-symbol #'draw-triangle)
)))
(:down-triangle
(lambda (x y)
(labels ((draw-triangle (&optional filled)
(gp:draw-polygon pane
(list (- x 3) (- y 3)
x (+ y 4)
(+ x 3) (- y 3))
:closed t
:filled filled)))
(draw-symbol #'draw-triangle)
)))
(:right-triangle
(lambda (x y)
(labels ((draw-triangle (&optional filled)
(gp:draw-polygon pane
(list (- x 3) (- y 3)
(+ x 4) y
(- x 3) (+ y 3))
:closed t
:filled filled)))
(draw-symbol #'draw-triangle)
)))
(:left-triangle
(lambda (x y)
(labels ((draw-triangle (&optional filled)
(gp:draw-polygon pane
(list (+ x 3) (- y 3)
(- x 4) y
(+ x 3) (+ y 3))
:closed t
:filled filled)))
(draw-symbol #'draw-triangle)
)))
(:dot
(lambda (x y)
(with-color (pane (adjust-color pane
(border-color symbol-style)
(border-alpha symbol-style)))
(gp:draw-circle pane x (1- y) 0.5))
))
)))
;; --------------------------------------------------------------------
(defmethod pw-plot-prepped ((pane plotter-pane) prepped symbol-fn
&key
;; (color #.(color:make-rgb 0.0 0.5 0.0))
;; alpha
;; thick
;; (linewidth (or thick 1))
;; linedashing
;; symbol
;; legend
legend-x
legend-y
legend-anchor
;; (border-color color)
;; symbol-filled
;; (fill-color color)
;; (border-thick linewidth)
;; barwidth
;; bar-offset
plot-style
symbol-for-legend
&allow-other-keys)
(when (legend plot-style)
(append-legend pane plot-style))
(when legend-x
(setf (plotter-legend-x pane) legend-x))
(when legend-y
(setf (plotter-legend-y pane) legend-y))
(when legend-anchor
(setf (plotter-legend-anchor pane) legend-anchor))
(with-plotview-coords (pane)
(gp:with-graphics-state (pane
;; :thickness linewidth
;; :dashed (not (null linedashing))
;; :dash linedashing
;; :foreground color
:line-end-style :butt
:line-joint-style :miter
;; :scale-thickness t ;; already present form WITH-PLOTVIEW-COORDS
:mask (plotter-mask pane))
(let+ ((xform (plotter-xform pane))
(line-style (line-style plot-style))
(symbol-style (and (not symbol-for-legend)
(symbol-style plot-style)))
(:mvb (_ y0) (gp:transform-point xform 0 0)))
(flet ((draw-lines ()
(gp:with-graphics-state (pane
:thickness (adjust-linewidth (line-thick line-style))
:foreground (adjust-color pane
(line-color line-style)
(line-alpha line-style))
:dashed (line-dashing line-style)
:dash (line-dashing line-style))
(gp:draw-polygon pane prepped))
))
(cond (symbol-style
(case (plot-symbol symbol-style)
((:vbars :hbars)
(gp:with-graphics-state (pane
:foreground (adjust-color pane
(fill-color symbol-style)
(fill-alpha symbol-style)))
(if (bar-width symbol-style)
(with-rects (prepped x y wd ht)
(gp:draw-rectangle pane
x y wd ht
:filled t))
;; else
(gp:draw-polygon pane prepped :filled t)
)))
(:sampled-data
(gp:with-graphics-state (pane
:foreground (adjust-color pane
(or (and line-style
(line-color line-style))
:black)
(or (and line-style
(line-alpha line-style))
1))
:thickness (adjust-linewidth (or (and line-style
(line-thick line-style))
1)))
(with-pts (prepped x y)
(gp:draw-line pane x y0 x y)
(funcall symbol-fn x y))
))
(otherwise
(when line-style
(draw-lines))
(with-pts (prepped x y)
(funcall symbol-fn x y)))
))
(line-style
(case (line-type line-style)
((:stepped :histo)
(gp:with-graphics-state (pane
:thickness (adjust-linewidth (line-thick line-style))
:foreground (adjust-color pane
(line-color line-style)
(line-alpha line-style)))
(gp:draw-polygon pane prepped)
))
(otherwise
(draw-lines))
))
))))))
;; --------------------------------------------------------------------
#|
(defmethod unsafe-pw-plot-xv-yv ((cpw plotter-pane) port xvector yvector
&key
;; (color #.(color:make-rgb 0.0 0.5 0.0))
;; alpha
;; thick
;; (linewidth (or thick 1))
;; linedashing
;; symbol
plot-joined
;; legend
legend-x
legend-y
legend-anchor
;; (border-color color)
;; symbol-filled
;; (fill-color color)
;; (border-thick linewidth)
;; barwidth
;; bar-offset
plot-style
symbol-for-legend
&allow-other-keys)
;; this is the base plotting routine
;; called only from within the pane process
;; (return-from unsafe-pw-plot-xv-yv)
(let+ (;; (color (adjust-color cpw color alpha))
;; (linewidth (adjust-linewidth linewidth))
(line-style (line-style plot-style))
(symbol-style (and (not symbol-for-legend)
(symbol-style plot-style)))
(nel (if xvector
(min (length-of xvector) (length-of yvector))
(length-of yvector)))
(xlog (plotter-xlog cpw))
(xlogfn (logfn xlog))
(ylog (plotter-ylog cpw))
(ylogfn (logfn ylog))
(xs (let ((scanner (make-scanner (or xvector
nel))
))
(if xlog
(make-transformer scanner xlogfn)
scanner)))
(ys (let ((scanner (make-scanner yvector)))
(if ylog
(make-transformer scanner ylogfn)
scanner)))
(pairs (make-pair-scanner xs ys))
(xform (plotter-xform cpw))
(xfpairs (make-gpxform-pairs xform pairs))
(:mvb (x0 y0) (gp:transform-point xform 0 0)))
(when (legend plot-style)
(append-legend cpw plot-style))
(when legend-x
(setf (plotter-legend-x cpw) legend-x))
(when legend-y
(setf (plotter-legend-y cpw) legend-y))
(when legend-anchor
(setf (plotter-legend-anchor cpw) legend-anchor))
(with-plotview-coords (cpw port)
(gp:with-graphics-state (port
;; :thickness linewidth
;; :dashed (not (null linedashing))
;; :dash linedashing
;; :foreground color
:line-end-style :butt
:line-joint-style :miter
;; :scale-thickness t ;; already present form WITH-PLOTVIEW-COORDS
:mask (plotter-mask cpw))
(labels ((draw-lines ()
(let* ((xfpairs (case plot-joined
((:spline)
(make-gpxform-pairs xform
(make-pairs-for-spline pairs)))
(otherwise
xfpairs))))
(gp:with-graphics-state (port
:thickness (adjust-linewidth (line-thick line-style))
:foreground (adjust-color cpw
(line-color line-style)
(line-alpha line-style))
:dashed (line-dashing line-style)
:dash (line-dashing line-style))
(gp:draw-polygon port (collect-pairs xfpairs))
))))
(cond (symbol-style
(case (plot-symbol symbol-style)
(:vbars
(gp:with-graphics-state (port
:foreground (adjust-color port
(fill-color symbol-style)
(fill-alpha symbol-style)))
(if (bar-width symbol-style)
(let* ((wd (get-x-width port (bar-width symbol-style)))
(wd/2 (* 0.5 wd))
(off (if (bar-offset symbol-style)
(get-x-width cpw (bar-offset symbol-style))
0)
))
(with-pairs (xfpairs x y)
(gp:draw-rectangle port
(+ off (- x wd/2)) y0
wd (- y y0)
:filled t)
))
(let ((xys (histo-vbars-pairs xfpairs y0)))
(gp:draw-polygon port xys :filled t)
))))
(:hbars
(gp:with-graphics-state (port
:foreground (adjust-color port
(fill-color symbol-style)
(fill-alpha symbol-style)))
(if (bar-width symbol-style)
(let* ((wd (get-y-width port (bar-width symbol-style)))
(wd/2 (* 0.5 wd))
(off (if (bar-offset symbol-style)
(get-y-width port (bar-offset symbol-style))
0)
))
(with-pairs (xfpairs x y)
(gp:draw-rectangle port
x0 (+ off (- y wd/2))
(- x x0) wd
:filled t)
))
(let ((xys (histo-hbars-pairs xfpairs x0)))
(gp:draw-polygon port xys :filled t)
))))
(:sampled-data
(gp:with-graphics-state (port
:foreground (adjust-color port
(or (and line-style
(line-color line-style))
:black)
(or (and line-style
(line-alpha line-style))
1))
:thickness (adjust-linewidth (or (and line-style
(line-thick line-style))
1)))
(let ((dotfn (get-symbol-plotfn port (symbol-style plot-style))))
(with-pairs (xfpairs x y)
(gp:draw-line port x y0 x y)
(funcall dotfn x y))
)))
(otherwise
(when line-style
(draw-lines))
(let ((plotfn (get-symbol-plotfn port symbol-style)))
(with-pairs (xfpairs x y)
(funcall plotfn x y)
)))
))
(line-style
(case (line-type line-style)
(:stepped
(gp:with-graphics-state (port
:thickness (adjust-linewidth (line-thick line-style))
:foreground (adjust-color port
(line-color line-style)
(line-alpha line-style)))
(gp:draw-polygon port (stairstep-pairs xfpairs))
))
(:histo
(gp:with-graphics-state (port
:thickness (adjust-linewidth (line-thick line-style))
:foreground (adjust-color port
(line-color line-style)
(line-alpha line-style)))
(gp:draw-polygon port (histo-pairs xfpairs))
))
(otherwise
(draw-lines))
))
)))
)))
(defmethod pw-plot-xv-yv ((cpw plotter-pane) port xvector yvector &rest args)
(let ((state (plotter-cache-state cpw)))
(when (or (null state)
(eql state (getf args :cache :drawing)))
(progn ;; ignore-errors
(apply #'unsafe-pw-plot-xv-yv cpw port xvector yvector args)))
))
|#
;; ------------------------------------------------------------------------------
(defun get-bar-symbol-plotfn (pane symbol color neg-color bar-width testfn)
;; bear in mind that the y values at this point are absolute screen
;; coords and are inverted with respect to data ordering
(ecase symbol
(:sigma
(lambda (x ys)
(destructure-vector (ymin ymax) ys
(gp:draw-line pane x ymin x ymax)
(gp:draw-line pane (- x (/ bar-width 2)) ymin (+ x (/ bar-width 2)) ymin)
(gp:draw-line pane (- x (/ bar-width 2)) ymax (+ x (/ bar-width 2)) ymax)
)))
(:hl-bar
(lambda (x ys)
(destructure-vector (ymin ymax) ys
(gp:draw-line pane x ymin x ymax)
)))
(:hlc-bar
(lambda (x ys)
(destructure-vector (h l c) ys
(gp:draw-line pane x l x h)
(gp:draw-line pane x c (+ x (/ bar-width 2)) c)
)))
(:ohlc-bar
(lambda (x ys)
(destructure-vector (o h l c) ys
(with-color (pane (if (funcall testfn c o) neg-color color))
(gp:draw-line pane x l x h)
(gp:draw-line pane (- x (/ bar-width 2)) o x o)
(gp:draw-line pane x c (+ x (/ bar-width 2)) c)
))))
(:candlestick
(lambda (x ys)
(destructure-vector (o h l c) ys
(if (funcall testfn c o)
(with-color (pane neg-color)
(gp:draw-line pane x l x h)
(gp:draw-rectangle pane (- x (/ bar-width 2)) o bar-width (- c o)
:filled t))
(progn
(with-color (pane :black)
(gp:draw-line pane x l x h))
(with-color (pane color)
(gp:draw-rectangle pane (- x (/ bar-width 2)) o bar-width (- c o)
:filled t))
(with-color (pane :black)
(gp:draw-rectangle pane (- x (/ bar-width 2)) o bar-width (- c o)))
))
)))
))
;;-------------------------------------------------------------------
(defmethod pw-plot-bars-xv-yv ((pane plotter-pane) xvector yvectors
&key
(color #.(color:make-rgb 0.0 0.5 0.0))
(neg-color color)
alpha
thick
(linewidth (or thick 1))
(bar-width 6)
(symbol (ecase (length yvectors)
(2 :sigma)
(3 :hlc-bar)
(4 :ohlc-bar)))
&allow-other-keys)
;; this is the base bar-plotting routine
;; called only from within the pane process
(let* ((xform (plotter-xform pane))
(color (adjust-color pane color alpha))
(neg-color (adjust-color pane neg-color alpha))
(linewidth (adjust-linewidth linewidth))
(nel (let ((nely (reduce #'min (mapcar #'length-of yvectors))))
(if xvector
(min (length-of xvector) nely)
nely)))
(xlog (plotter-xlog pane))
(xlogfn (logfn xlog))
(ylog (plotter-ylog pane))
(ylogfn (logfn ylog))
(xs (let* ((xform (lambda (x)
(gp:transform-point xform x 0)))
(scanner (make-scanner (or xvector
nel)
:max-items nel)))
(make-transformer scanner
(if xlog
(um:compose xform xlogfn)
xform))
))
(xform-y (lambda (y)
(second (multiple-value-list
(gp:transform-point xform 0 y)))
))
(ys (let* ((scanners (mapcar #'make-scanner yvectors)))
(mapcar (um:rcurry #'make-transformer
(if ylog
(um:compose xform-y ylogfn)
xform-y))
scanners)
))
(c<o-testfn (let ((y1 (funcall xform-y 0))
(y2 (funcall xform-y 1)))
(if (< y2 y1)
#'>
#'<)))
(plotfn (get-bar-symbol-plotfn pane symbol
color neg-color bar-width
c<o-testfn))
(tmp (make-array (length ys))))
(with-plotview-coords (pane)
(gp:with-graphics-state (pane
:thickness linewidth
:foreground color
:line-end-style :butt
:line-joint-style :miter
:mask (plotter-mask pane))
(with-scanner (xs x)
(map-into tmp #'next-item ys)
(funcall plotfn x tmp)))
)))
;; ============================================================
(declaim (inline /2))
(defun /2 (x)
(/ x 2))
(defun plt-draw-shape (pane shape x0 y0
&key
width height radius to
color alpha filled
border-thick border-color border-alpha
start-angle sweep-angle raw
&allow-other-keys)
;; For :rect, (x0,y0) = ctr, (wd,ht) are width, height
;; For :ellipse (x0,y0) = ctr, (wd,ht) are radii
;; For :arc (x0,y0) = ctr, (wd,ht) are radii, sweep and start angles are radian measure
(let* ((color (adjust-color pane color alpha))
(bcolor (adjust-color pane border-color border-alpha))
(linewidth (adjust-linewidth (or border-thick 0)))
(x0 (get-x-location pane x0))
(y0 (get-y-location pane y0)))
(labels
((draw-fns ()
(labels ((draw (shape-fn)
(labels ((do-drawing ()
(gp:with-graphics-state (pane
:thickness linewidth
:foreground color
:line-end-style :butt
:line-joint-style :miter)
(when filled
(funcall shape-fn :filled t))
(when border-thick
(with-color (pane bcolor)
(funcall shape-fn :filled nil)))
)))
(if raw
(do-drawing)
(gp:with-graphics-state (pane
:mask (plotter-mask pane))
(do-drawing))
))))
(ecase shape
(:line
(let ((x1 (get-x-location pane (car to)))
(y1 (get-y-location pane (cdr to))))
(draw (um:curry #'gp:draw-line pane x0 y0 x1 y1))
))
(:rect
(let ((wd (get-x-width pane width))
(ht (get-y-width pane height)))
(draw (um:curry #'gp:draw-rectangle pane
(- x0 (/2 wd)) (- y0 (/2 ht)) wd ht))
))
(:ellipse
(let ((wd (get-x-width pane width))
(ht (get-y-width pane height)))
(draw (um:curry #'gp:draw-ellipse pane x0 y0 wd ht))))
(:arc
(let ((wd (get-x-width pane width))
(ht (get-y-width pane height)))
(draw (um:curry #'gp:draw-arc pane
(- x0 (/2 wd)) (- y0 (/2 ht)) wd ht
start-angle sweep-angle))
))
(:circle
(let ((rad (get-x-width pane radius)))
(draw (um:curry #'gp:draw-circle pane x0 y0 rad))
))
))))
(if raw
(draw-fns)
(with-plotview-coords (pane)
(draw-fns)))
)))