Skip to content

Commit f4286d4

Browse files
committed
adjust pict-returning functions to convert from racket picts to rhombus picts
1 parent 5403392 commit f4286d4

File tree

2 files changed

+45
-22
lines changed

2 files changed

+45
-22
lines changed

redex-pict-lib/redex/private/pict-interface.rkt

+40-17
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,46 @@
3636
(rename-out
3737
[p:pict-width pict-width]
3838
[p:pict-height pict-height]
39+
[p:pict-descent pict-descent]
3940
[p:pict? pict?]
4041
[p:draw-pict draw-pict]
41-
[p:dc dc]
4242
[p:text-style/c text-style/c]
43-
[p:blank blank]
44-
[p:pict-descent pict-descent]
45-
[p:text text]
46-
[p:dc-for-text-size dc-for-text-size]
47-
[p:filled-rectangle filled-rectangle]))
43+
[p:dc-for-text-size dc-for-text-size]))
44+
45+
(define (to-rhm-pict p)
46+
(choose p (r:from_handle p)))
47+
48+
(provide dc
49+
blank
50+
text
51+
filled-rectangle)
52+
53+
(define (dc draw w h [a h] [d 0])
54+
(to-rhm-pict (p:dc draw w h a d)))
55+
56+
(define blank
57+
(case-lambda
58+
[() (to-rhm-pict (p:blank))]
59+
[(s) (to-rhm-pict (p:blank s))]
60+
[(w h) (to-rhm-pict (p:blank w h))]
61+
[(w a h) (to-rhm-pict (p:blank w a h))]
62+
[(w h a d) (to-rhm-pict (p:blank w h a d))]))
63+
64+
(define (text content [style '()] [size 12] [angle 0])
65+
(to-rhm-pict (p:text content style size angle)))
66+
67+
(define (filled-rectangle w h
68+
#:draw-border? [draw-border? #t]
69+
#:color [color #f]
70+
#:border-color [border-color #f]
71+
#:border-width [border-width #f])
72+
(to-rhm-pict
73+
(filled-rectangle w h
74+
#:draw-border? draw-border? #:color color
75+
#:border-color border-color #:border-width border-width)))
4876

4977
(define-rhombus
5078
(lib "pict/main.rhm")
51-
rectangle ;; just temporary
5279
beside
5380
stack
5481
overlay
@@ -117,7 +144,6 @@
117144
#'(begin
118145
(provide name)
119146
(define (name arg1 . args)
120-
(printf ">> ~s ~s ~s\n" name rhombus-name (cons arg1 args))
121147
(choose
122148
(apply racket-name arg1 args)
123149
(keyword-apply rhombus-name
@@ -129,9 +155,7 @@
129155
(list (if (number? arg1) arg1 0) rhombus-kwd-value))
130156
(if (number? arg1)
131157
args
132-
(let ([ans (cons arg1 args)])
133-
(printf "?? ~s\n" ans)
134-
ans))))))]))
158+
(cons arg1 args))))))]))
135159

136160
(define-append ht-append
137161
p:ht-append
@@ -164,7 +188,6 @@
164188
#'(begin
165189
(provide name)
166190
(define (name . args)
167-
(printf "calling ~s with ~s\n" name args)
168191
(choose
169192
(apply racket-name args)
170193
(apply r:overlay #:horiz horiz #:vert vert args))))]))
@@ -189,18 +212,18 @@
189212

190213
(define-namespace-anchor ns-anchor)
191214
(define ns (namespace-anchor->namespace ns-anchor))
192-
(define r:find
215+
(define-values (r:find r:from_handle)
193216
(cond
194217
[(rhombus-present?)
195218
(parameterize ([current-namespace ns])
196219
(namespace-require '(all-except rhombus #%top))
197220
(namespace-require 'rhombus/parse)
198221
(namespace-require 'redex/private/rhombus-bridge)
199-
;(eval `(rhombus-top (group def π (op =) 3.14)))
200-
;(eval 'π)
201-
(eval 'find))]
222+
(values (eval 'find)
223+
(eval 'from_handle)))]
202224
[else
203-
#f]))
225+
(values "dummy value that's not rhombus's find"
226+
"dummy value that's not rhombus's find_handle")]))
204227
(define-syntax (define-finder stx)
205228
(syntax-parse stx
206229
[(_ name racket-name horiz vert)

redex-pict-lib/redex/private/rhombus-bridge.rkt

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
// on rhombus by replacing this file with
77
// racket code that does the same thing
88

9-
import:
10-
pict open
11-
12-
export:
13-
find
9+
import: pict open
10+
export: find from_handle
1411

1512
fun find(pict,sub,h,v):
1613
Find(sub, ~horiz: h, ~vert: v).in(pict)
14+
15+
fun from_handle(p):
16+
Pict.from_handle(p)

0 commit comments

Comments
 (0)