Gas station without pumps

2019 January 8

One figure has been giving me grief for a long time

Filed under: Circuits course — gasstationwithoutpumps @ 09:22
Tags: , , ,

There is one figure in my book that has been giving me trouble for a long time:

A Moiré pattern figure for the sampling and aliasing chapter that was giving me trouble.

The figure itself is very simple, and it should have been no trouble at all. I created the figure in hand-written SVG, and all the SVG readers (Inkscape, Preview, and browsers) had no trouble rendering it on the screen. But when Inkscape converted it to PDF (using the Cairo library, I believe), it threw away the black bars in the background. When I asked Inkscape to print the image to PDF, it rotated the image.

For a while, I got away with rerotating the image in Preview and saving the result, but the file got damaged or deleted at some point, and redoing the rotation in Preview no longer worked—pdflatex seemed to have no idea that there was a rotation nor a bounding box any more.  (I think Preview changed when I upgraded the mac OS on my laptop.) This change happened between the 2018 Dec 15 and 2018 Dec 30 releases of the book, so the Dec 30 release had a messed-up figure without my realizing it.

Yesterday evening, I noticed the problem and set about trying to fix it.  Nothing I could do with Inkscape or Preview seemed to work—I either ended up with no black bars or with the image rotated and scaled wrong.  (Viewing the individual image with Preview sometimes worked—but the inclusion by pdflatex was failing in those cases.)

Finally, I decided that since Inkscape was incapable of rendering in PDF the pattern-fill I was using to create the bars, that I would give up on pattern fill to create them.  Instead I used a Python program to generate separate rectangles.  Inkscape had no trouble converting that longer but less sophisticated SVG program to PDF, and I was able to fix the figure.

Because this figure was messed up in the “final” release of 30 Dec 2018, I did a quick re-release last night, fixing this figure and a bunch of typos students had found.  Yesterday was the first day of class, and students have already reported 7 errors in the book (one reported after yesterday’s release, so it is still in the current version at LeanPub).

This year’s class seems to be very diligent, as all the students had the book downloaded by the first day of class, and some had started on the homework.

3 Comments »

  1. Sounds like your problem is fixed, but I just wanted to point out an inkscape feature that would have allowed you to do this without using a python script. You draw one black rectangle, duplicate it in-place 32 times, move one rectangle to the right, select them all and use the “Align and distribute” tool named “Distribute centers equidistantly horizontally” (doesn’t actually matter which horizontal distribution tool you use since the boxes are equal-width).

    Comment by RFon — 2019 January 8 @ 10:10 | Reply

    • I considered that approach originally, but Inkscape makes it a little difficult to be precise about pitch that way, and the figure needed to have precise pitches. If I was just going for a visual effect, that would have worked ok. With some fiddling, I could have gotten the precise pitches I needed, but writing a Python script was faster and more easily modified if I need to change anything, since all the parameters (bar widths, pitches, overall width, heights, …) are variables that I can easily change.

      Comment by gasstationwithoutpumps — 2019 January 8 @ 10:19 | Reply

  2. […] in my book had gotten messed up between the Dec 15 and Dec 30 releases, and I had to come up with a new way to create the figure and re-release the book. LeanPub is nice in that anyone who has bought the book can pick up the new releases for free.  I […]

    Pingback by Struggles with Canvas | Gas station without pumps — 2019 January 8 @ 11:30 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply to gasstationwithoutpumps Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: