nicola.palumbo
2019-3-19 11:27:08

@nicola.palumbo has joined the channel


sorawee
2019-3-19 13:08:26

Ideally, I want to write @defproc[(flip-horiz [p painter?]) painter?]. The problem is that painter? is actually not a thing. Rather, a painter is an alias of a function that consumes a frame? and produces a frame?. What’s the best way to document this?

My options seem to be:

  • @defproc[(flip-horiz [p (-> frame? frame?)]) (-> frame? frame?)]: I don’t like this. It’s super unreadable.
  • @defproc[(flip-horiz [p procedure?]) procedure?]: I also don’t like this as it’s very imprecise.
  • (define painter? (-> frame? frame?)) and then document painter? and flip-horiz (in terms of painter?).

Which is the best? And is there a better way?


mflatt
2019-3-19 13:48:43

I vaguely recalled something about -l and user-scope packages, but had to check the raco exe docs… Assuming that “rsound” is installed as a user-scope package, try --exf -U as flags to raco exe.


ryanc
2019-3-19 13:53:18

@sorawee Option 3 is probably best, but you should name it painter/c instead of painter?, since it is a higher-order contract and not a predicate. Another alternative is to @deftech the word “painter” somewhere in your document and then use #, @tech{painter} (or #,(tech "painter") or IIRC @#,painter{tech}) as the “contract” on the argument and result. But defining and documenting painter/c is better.


sorawee
2019-3-19 13:55:18

Thanks!



lexi.lambda
2019-3-19 14:31:38

sighs


lexi.lambda
2019-3-19 14:32:18

I wish those questions had reasonable answers. But R7RS just specifies too little.


samth
2019-3-19 14:34:25

Part of the answer is #!r7rs, right?


samth
2019-3-19 14:34:37

and another part of the answer is include


samth
2019-3-19 14:34:48

and a third part is “give up on portable scheme code”


ben
2019-3-19 14:37:53

@robby @stamourv the northwestern current snapshots are all broken links: https://plt.eecs.northwestern.edu/snapshots/current/


robby
2019-3-19 14:38:28

I don’t think @stamourv is involved in that.


ben
2019-3-19 14:38:49

ok, I wasn’t sure. Just ping Robby next time?


robby
2019-3-19 14:39:00

sure. I’m investigating


robby
2019-3-19 14:42:51

Looks like the rsync mysteriously failed last night.


robby
2019-3-19 14:42:56

No disks appear to be full.


robby
2019-3-19 14:43:08

from the sending side:


robby
2019-3-19 14:43:10
2019/03/18 16:34:34 [42315] rsync: connection unexpectedly closed (66896 bytes received so far) [sender]
2019/03/18 16:34:34 [42315] rsync error: unexplained error (code 255) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-52/rsync/io.c(453) [sender=2.6.9]

robby
2019-3-19 14:43:38

it should be doing today’s rsync soon, so I guess the best course is to just let things go and check back in, in a few hours.


robby
2019-3-19 14:44:13

Northwestern is making a transition from being an EECS department to being two departments (CS and ECE) and so that might lead to things getting a bit wonky here and there.


robby
2019-3-19 14:44:19

Not sure if that’s what happened here, tho.


robby
2019-3-19 14:45:29

oh, it might actually still be a few hours. I see that today’s build hasn’t started the docs yet (altho yesterday’s started them at some point in the 7am hour (it is nearly 10am here))


robby
2019-3-19 14:46:01

If things go wrong again today, I’ll involve our tech staff (who run the machine that the rsync (that failed) connects to).


robby
2019-3-19 14:46:20

Thanks for letting mek now.


lexi.lambda
2019-3-19 14:51:24

@samth R7RS doesn’t specify #!r7rs, either, only R6RS specifies #!r6rs.


samth
2019-3-19 14:51:35

damn


lexi.lambda
2019-3-19 14:51:39

It’s hopeless.


samth
2019-3-19 14:51:57

ok, switching fully to my third thought


stamourv
2019-3-19 14:52:23

@ben, @robby: Indeed.


fharvell
2019-3-19 16:24:51

@fharvell has joined the channel


samdphillips
2019-3-19 17:36:37

I started on a R7RS Large Red Edition package, but I don’t know if I have the patience of @lexi.lambda to deal with tech support for it.


lexi.lambda
2019-3-19 17:37:12

Tech support for R7RS small is easy. The answer to almost every issue is “sorry, R7RS doesn’t specify that”. :)


samdphillips
2019-3-19 17:44:31

Also if I wasn’t really going to use it the only point would be for 100% completion (and engineering challenge) sake.


blerner
2019-3-19 19:51:30

Question about pict and bounding boxes and curves: I have the following function, that’s supposed to draw a filled dot, and an arrow coming down to the right and bending in to point to the left: (require (prefix-in p: pict)) (define (right-curve height) (define rad 5) (define dot (p:disk (* 2 rad) #:color "black" #:draw-border? #f)) (define tip (p:blank)) (define img (p:pin-over dot rad height tip)) (p:frame (p:panorama (p:pin-arrow-line (* 2 rad) img dot p:cc-find tip p:cc-find #:start-angle (* pi 7/4) #:end-angle pi #:color "red")))) (right-curve 50) When I run this code in DrR, though, the resulting image (a) takes up twice as much height at the repl as the frame itself does, and (b) the frame is cropped in tightly to the disk and the arrowhead, but the curve is clipped, despite calling panorama to enlarge the bounding box. I’m not too concerned about the REPL weirdness (unless it causes the picture to behave badly in scribble later, but that’s a problem for later). But is there any way for me to ensure that the bounding box of the pict is automatically enlarged to include the curvy line? Or failing that, is there an alternative to pin-arrow-line that gives me bezier curves and arrowheads?


blerner
2019-3-19 19:53:18

I’ve found the metapict/bez library, which intrigues me, but I’d love it if I didn’t have to compute the control points myself :wink:


soegaard2
2019-3-19 19:54:57

You can use curve from MetaPict to compute the control points.


soegaard2
2019-3-19 19:56:28

Example: (curve p1 .. p2 .. pt3 .. pt4) will draw a “nice” curve through the points.


soegaard2
2019-3-19 19:56:48

replace one of the .. with — to get a straight line between two of the points.


soegaard2
2019-3-19 19:57:47

If the curve needs to enter or leave a point in a particular direction, you can do:


soegaard2
2019-3-19 19:58:15

(curve direction-to-enter p1 direction-to-leave .. p2 …)


soegaard2
2019-3-19 19:58:33

The enter and leave directions are optional everywhere.


blerner
2019-3-19 19:58:59

what’s the syntax for directions? are they angles (deg or rad), or keywords, or…?


soegaard2
2019-3-19 19:59:43

The directions are represented as vectors using a vec structure.


soegaard2
2019-3-19 20:00:07

E.g. (vec 1 0) will be the east direction.


blerner
2019-3-19 20:00:13

ah, ok, cool


soegaard2
2019-3-19 20:00:30

up left right down are predefined


soegaard2
2019-3-19 20:01:18

There is also a function that takes a number of degrees and return a unit vector in that direction.


samth
2019-3-19 20:01:22

I don’t understand why panorama isn’t taking the line into account


samth
2019-3-19 20:01:33

my guess is that the line isn’t actually represented as a sub-pict


samth
2019-3-19 20:01:47

but that behavior seems like a bug


blerner
2019-3-19 20:01:49

@samth, is the code snippet I have above producing the same clipping output for you?


samth
2019-3-19 20:01:52

yes


samth
2019-3-19 20:02:15

if you just have one particular image, you can fix it with inset


samth
2019-3-19 20:02:26

but in general this seems not-good


blerner
2019-3-19 20:03:18

looking at pict-lib/pict/private/main.rkt pin-curve*, seems like it’s just building a dc-path% and directly sending move-to and curve-to messages


blerner
2019-3-19 20:03:34

doesn’t seem like there’s a pict structure being created for the curve itself


blerner
2019-3-19 20:03:37

@soegaard2 so that gets me part of the way there… looks like metapict will give me picts, so that’s relatively easy to compose with other picts. last bit of the puzzle: how do I draw arrowheads of a given size, and how do I shorten the bezier curve to give room for the arrowhead at the end of it?


samth
2019-3-19 20:03:43

yeah that was my guess


soegaard2
2019-3-19 20:07:02
#lang racket
(require metapict)

(define p (pt 0 1))
(define q (pt 0 0))

(draw (fill (circle p 0.1))
      (color "red"
             (draw-arrow (curve p .. left q))))

soegaard2
2019-3-19 20:07:43

The function draw-arrow will draw the curve with an arrow in the end.


blerner
2019-3-19 20:08:14

Does draw-arrow produce a pict that I can combine with other picts? And, can I customize the arrowhead itself?


blerner
2019-3-19 20:08:40

(Looking at the metapict docs, but most of the links are broken/incomplete, so I haven’t figured it out yet myself)


soegaard2
2019-3-19 20:08:54

Yes. draw-arrow returns a pict.



soegaard2
2019-3-19 20:09:09

for different arrow heads and the parameters that can be tweaked.


soegaard2
2019-3-19 20:09:46

And I agree - the documentation is not done.


blerner
2019-3-19 20:10:15

no worries — thanks for the help so far :slightly_smiling_face:


soegaard2
2019-3-19 20:10:39

The idea is that the settings are done using the parameters beginning at line 24.


soegaard2
2019-3-19 20:11:03

Normally I don’t need to change anything but the arrow head length using ahlength.


soegaard2
2019-3-19 20:11:57

Well - if you only need to change the settings for a single arrow, than use the keywords. See line 161.


blerner
2019-3-19 20:12:05

cool, ok. when using draw-arrow, does it place the arrow so that the tip of the arrowhead is the anchor point of the curve, or the inner notch is? (IIRC, in tikz, you can control this because, naturally, everything is tweakable in tikz…and I don’t remember what the defaults were)


soegaard2
2019-3-19 20:12:49

It places the arrow head on the anchor point (not the notch).


blerner
2019-3-19 20:12:54

yay :slightly_smiling_face:


soegaard2
2019-3-19 20:13:51

Also … If you curve is say a circle, you can get your arrow head to “bend”. (I think - I can’t remember if I changed my mind)


soegaard2
2019-3-19 20:16:00

Oh. And if you just need to the bezier control points, then just use curve which basically is a struct holding a list of bez structures.


blerner
2019-3-19 20:20:11

well, with only the control points, I won’t get the right bounding box (unless I compute it myself…) I’m hoping that curve implicitly gets it right for me, because of subdivision


blerner
2019-3-19 20:24:13

Is there a way to avoid using the window as my bounding box, and pick whatever is tightest on the actual drawing?


blerner
2019-3-19 20:24:29

(i.e. the equivalent of panorama?)


soegaard2
2019-3-19 20:24:38

looks up panaroma



soegaard2
2019-3-19 20:27:58

I haven’t anything built-in. But I think it ought to be doable.


soegaard2
2019-3-19 20:28:31

I have a bez-large-bounding-box which computes an approximate (may be too large) bounding box.


soegaard2
2019-3-19 20:29:22

And sfont has a bezier-bounding-box which could be used.


soegaard2
2019-3-19 20:30:21

Also a dc-path has a (send a-dc-path get-bounding-box) method.


justin.hu
2019-3-19 20:30:43

Hello, all: I’m currently writing an indentation checker for teaching language files. I’d like to be able to take a file, run the DrRacket autoindenter on it, then diff the files, but I don’t think I can invoke that functionality in a convenient way. My alternate strategy is to read through the syntax objects, and calculate what the expected indentation(s) should be. Unfortunately, I can’t find how many lines a syntax object spans in a nice way. Anyone have advice?


samth
2019-3-19 20:32:00

@justin.hu to figure out the lines spanned, you need to look at the syntax-span and then see if there are newlines in the actual bytes


samth
2019-3-19 20:32:08

which I agree doesn’t seem nice


justin.hu
2019-3-19 20:32:40

Drat…. Anyone know how to invoke the DrRacket indenter?


samth
2019-3-19 20:32:58

You ought to be able to run the indenter automatically, but I don’t know how easily



soegaard2
2019-3-19 20:36:06

@blerner The sfont code does compute the proper bounding box for a Bezier curve. So given a curve (a list of Bezier curves) we need to compute the bounding box for each and then combine them.


soegaard2
2019-3-19 20:36:52

But this gives the bounding box in virtual coordinates. When the curve is drawn the pen size etc will affect the real bounding box.


soegaard2
2019-3-19 20:37:17

I am not sure how to deal with that.


blerner
2019-3-19 20:40:25

worst case, just inflate the box by half the pen width? (That’s ignoring pen-cap details, but I’m ok with that for now)


samth
2019-3-19 20:42:42

@justin.hu here: #lang racket (require framework) (define (indent s) (define t (new racket:text%)) (send t insert s) (send t tabify-all) (send t get-text)) (indent "(lambda (x)\nx)")


justin.hu
2019-3-19 20:43:04

Thanks.


soegaard2
2019-3-19 20:44:45

@blerner Yeah - ought to work.


soegaard2
2019-3-19 20:47:55

But it will still result in a bounding box for a single curve only.


soegaard2
2019-3-19 20:48:18

The draw operation simply draws stuff on top of a pict.


soegaard2
2019-3-19 20:48:46

Or rather it constructs a pict.


soegaard2
2019-3-19 20:49:04

So … maybe panorama works on the result?


soegaard2
2019-3-19 20:51:02

Nope. Wishfull thinking.


soegaard2
2019-3-19 20:51:29

MetaPict of course sets the bounding box - so panorama doesn’t have a chance.


blerner
2019-3-19 20:57:20

well, but then you can cheat, and say (inset (inset the-metapict (- the-pict-bounding-box) ...) the-metapict-bounding-box ...), so that maybe you can force the bounding box to be what you want, so that panorama gets the right info?


blerner
2019-3-19 20:57:52

I’m fine with producing a floating pict that I need to combine with an existing pict myself


blerner
2019-3-19 21:27:19

@samth is there a pict function that’s the opposite of ghost, that says “draw this pict but pretend it has a zero-size bbox”?


florence
2019-3-19 21:31:51

@blerner a cheap-trick ive used for that before:

(let ([x (blank)])
    (refocus (ht-append x the-pict) x))

blerner
2019-3-19 21:31:59

hehe


blerner
2019-3-19 21:32:07

that makes total sense


mflatt
2019-3-19 21:32:25

I was going to suggest inset with negative values, but that’s better.


samth
2019-3-19 21:38:24

@mflatt any thoughts on the issue of lines and panorama that @blerner has?


mflatt
2019-3-19 21:42:10

No ideas. As you’ve worked out, pin-arrow-line doesn’t add information that panorama can use.


ben
2019-3-19 21:42:18

Today’s build worked :)


blerner
2019-3-19 23:33:29

@soegaard2 I gotta step away from the computer for a little while, but istm that https://docs.racket-lang.org/metapict/index.html?q=metapict#%28part._ref-draw-and-fill%29 doesn’t quite play nicely with the rest of the pict ecosystem. Instead of using curve-pict-width and curve-pict-height parameters, I think you can compute the correct bbox of the curve, in logical coordinates, and add onto it any decorations like arrowheads. Then things like panorama and inset and clip will all behave “the same way” as they do on other picts.


blerner
2019-3-19 23:34:41

In my case, since I happen to know something algebraic about the control points of my curve, I can figure out that (point-at c 0.5) is an extremal point of the curve, so I can figure out my bounding box for now on my own. But because draw-arrow doesn’t actually add a pict for the arrowhead, it gets clipped away… fortunately, that won’t matter for my overall image, but in general, it’s slightly awkward.


matias
2019-3-20 00:21:20

ooooo fun, I got racket to segfault


matias
2019-3-20 00:38:34

oh, one of the libraries I’m using is doing unsafe stuff internally.


matias
2019-3-20 00:38:38

that’s less exciting.


matias
2019-3-20 02:56:44

is there a way to get scribble to spit out SVGs instead of PNGs?


matias
2019-3-20 02:57:43

oh, duh. --help


blerner
2019-3-20 03:21:39

Another question about picts: Suppose I just use the standard (arrowhead 10 0) pict. I get an arrowhead, no biggie. If I frame it, I get a tightly fitting box. If I use @florence’s trick above (using cc-superimpose instead, to get things centered), and say (frame (smash (arrowhead 10 0))), I get an empty pict: pict-width returns 0. If I try to rotate it, though, things go wrong. Specifically, if I try (pict-width (panorama (smash (rotate (arrowhead 10 0) pi)))), I get a width of 20. Huh? Without the rotate, I get a width of 10 as expected…


florence
2019-3-20 03:26:59

Pict bounding boxes are rectangles. So if you rotate by 45 degrees (that’s what pi is right? I never remember…) the width should be the length of the diagonal, not the length of the side


blerner
2019-3-20 03:27:38

pi is 180 degrees


florence
2019-3-20 03:27:55

Oh…whelp back to basic trig for me


blerner
2019-3-20 03:32:42

(also, if it were 45 degrees, I’d wind up with a width of 10*sqrt(2) = 14.1… :wink: )


florence
2019-3-20 03:37:05

(fwiw I can trigger this without smash, just using panorama and rotate)


blerner
2019-3-20 03:37:43

ok, so that’s a useful simplification.


mark
2019-3-20 06:46:31

OK, that worked!