Ben Crowder

Blog: #svg

15 posts :: tag feed :: about the blog :: archive

#drawbot #go #harfbuzz #ink #pagedjs #pdf #plotdevice #press #rust #svg #unicode #working-in-public

Update on Press (the PDF compiler). I haven’t worked on it at all lately, but I wanted to document its current state for history’s sake, and as part of working in public. (I’ve also been sitting on this post for over a year.)

Back in 2017 I did end up re-architecting Press to use Low Ink as an intermediate page description language. In the process, Low Ink changed from a JSON-based idea to this:

:page 11x8.5in
:bleedbox x=0.125in y=0.125in w=5.75in h=8.75in
:fontmap family=helv weight=regular style=normal standard=Helvetica
:yinvert
:push
:translate x=72 y=72

# ascender
:push
:translate x=0 y=1040
:strokecolor hex=#999
:linewidth 0.25pt
:line x1=0 y1=0 x2=1080 y2=0
:stroke
:push
:fillcolor hex=#999
:font family=helv size=14pt
:text x=1085 y=-3 text="ascender"
:pop
:pop

# filled glyph
:push
:translate x=1320 y=240
:fillcolor hex=#000
:moveto x=0 y=0
:pathto x=400 y=300 cx1=120 cy1=300 cx2=140 cy2=300
:pathto x=320 y=200 cx1=540 cy1=300 cx2=320 cy2=180
:lineto x=350 y=350
:lineto x=450 y=250
:lineto x=150 y=0
:moveto x=200 y=200
:lineto x=200 y=250
:lineto x=250 y=250
:lineto x=250 y=200
:lineto x=200 y=200
:fill
:pop

It was intended to be a fairly low-level wrapper on the PDF format, with the idea being that other libraries/apps would provide more ergonomic abstractions on top of it.

I initially used Python because Press started out as a library, but with the pivot to a compiler model, I think Go or Rust would probably end up being a better choice (Rust would make integrating HarfBuzz a bit easier, at any rate).

Potential improvements

To my 2021 eyes, the language design isn’t particularly elegant. I like that the parameters are named (clarity), but for most of the commands there aren’t actually that many parameters, because many of the settings that would normally be parameters are separate commands. For parameters that are clearly unambiguous, the names hamper readability. For example, I think something like this might be better:

:line 0,0 to 1080,0
:fillcolor #345

I’ve also thought that push and pop could potentially be clearer as curly braces, and that the initial colons aren’t really necessary:

{
  translate 0,1040
  strokecolor #999
  linewidth 0.25pt
  line 0,0 to 1080,0
  stroke

  {
    fillcolor #999
    font 14pt helv
    text 1085,-3 "ascender"
  }
}

The future

My initial reason for building Press was to have an easy, programmable cross-platform way to create language chart PDFs (so I could move away from PlotDevice/DrawBot), and what I’ve realized (acknowledging that I haven’t really been making language charts in recent years) is that there are some other, better options now.

One that seems decent is SVG, converted to PDF by way of Inkscape. Initial tests here seem like it would probably work fine.

Another promising option that I admittedly haven’t looked into very much yet is Paged.js. HTML and CSS are already great for declarative typesetting, and the more I’ve thought about programmatic typesetting, the more this model seems to be the future I’d want to work with (and not just because of parity with web, though that makes it much more compelling).

tl;dr I don’t see myself continuing on with Press, so we may as well call a mortem on it.


Reply via email or via office hours

#css #design #genealogy #html #sparklines #svg #web #working-in-public

Lately I’ve been playing around with implementing genealogy sparklines on the web. Still very much a work in progress, but I’m trying to do more working in public, so here’s the messy current status (and at some point I’ll post the actual HTML/CSS):

Ruby test

sparkline-test-002.png

Implementation notes:

  • The sparklines use inline SVG
  • This test uses the <ruby> and <rt> tags, with ruby-position set to under and ruby-align set to start (though only Firefox supports it so it’s not sadly viable for actual use yet)
  • I don’t really like that it makes the leading uneven (lines that have ruby vs. lines that don’t)

Design notes:

  • Rather than having solid squares at the births and deaths, I’ve gone for vertical lines so they’re less obtrusive (and have also considered just getting rid of the vertical lines, though I haven’t tried it out yet)
  • Circles are simple so I went with them for marriages and children

Absolute positioning test

sparkline-test-003.png

Implementation notes:

  • The names are wrapped in span tags with position: relative set, and the SVG gets position: absolute. Fairly simple.
  • Even leading!
  • There’s some wonkiness right now when the span is at the beginning of a line (the sparkline shows up at the end of the previous line), haven’t tried very hard to fix it yet

Reply via email or via office hours

#art #generative-art #python #releases #religious #svg

New artwork: The Gathering of Israel. For a few months I’d been thinking about how to symbolically represent this idea and eventually settled on a vector field (with artistic license rashly taken) as the best fit, at least for this version. The textures all generated in SVG via a small Python script.


Reply via email or via office hours

Links #41

#art #blogging #coding #food #generative-art #go #links #svg

Rob Weychert’s Plus Equals, a new zine about algorithmic art. The first issue was good, looking forward to future installments.

Riccardo Scalco’s Textures.js, SVG patterns for d3.js. Yum. I don’t even use d3 (at least not right now), but I’m tempted to do something with it just so I can use these.

Jason Kottke on the invention of a new pasta shape. Max sauceability as a concept will stick with me for a long time, I think.

Rytis Bieliunas on some of the darker corners of Go (the programming language). I’m writing a lot of Go at work now and this was helpful.

Austin Kleon on blogging as a forgiving medium. The idea of continually editing and refining posts after publishing them intrigues me. I fix typos if I find them, but that’s about it at the moment.


Reply via email or via office hours

#circle-packing #cirque #functional-programming #svg

A short update on Cirque:

I took out the turbulence filters, because they shouldn’t have been there in the first place (at least not the way I had them). Instead, I’m planning to build a tool that makes it easy to apply filters to SVG elements. It’ll be more generally useful, since the SVG input won’t have to have come from Cirque.

Manually placing circles is partway done. (Placing them works; editing and deleting them is next on the list.)

I’m also refactoring to clean things up and to make the imperative code more functional where I can.


Reply via email or via office hours

Introducing Cirque

#circle-packing #cirque #coding #generative-art #javascript #rust #svg #web #webassembly

As schoolwork starts to wind down, I’m finally starting to make progress on the creativity tools and HCI explorations I talked about back in September. This week I’ve also realized that graphical tools for art and design are what I want to focus most on. (I do still intend to explore textual interfaces, but they’re on the backburner for now.)

In the spirit of working in public, then, Cirque is a small WIP web app I’m building for making patterns via circle packing:

cirque-01.png
cirque-02.png
cirque-03.png
cirque-04.png

This is very much a rough initial MVP. You can tweak some settings, generate new patterns using a simple circle-packing algorithm, and export SVG (with the turbulence/displacement filters enabled by default), but that’s it. Some of the features I’m planning to build next:

  • Replace the settings text box with, you know, good UI (I’m also excited to explore color picker design here)
  • Add the ability to manually place both circles and anticircles (so artists are able to create intentional negative space)
  • Add a way to programmatically set the circle colors (probably via something like shaders, so you could say all circles smaller than a certain size get one color and the rest get another, or circle color is dependent on position or something else)

I’ve also thought about moving the circle packing code from JavaScript to Rust, to be able to play around with WebAssembly, but it seems overkill, at least at this point. (Instead I think I’ll plan to Rust and WebAssembly on the graphical type design tool I want to build.)


Reply via email or via office hours

#art #inkscape #photoshop #quicklook #releases #religious #svg

New artwork: Peace, Be Still. I dialed up the SVG turbulence filters to get the effect on the left. Also used the erode operator throughout (with the feMorphology filter primitive). I couldn’t get Inkscape to show the lines with the filters applied, though, so I ended up screenshotting the piece via QuickLook and then upscaling in Photoshop (hacky, but hopefully not too obvious).


Reply via email or via office hours

#art #illustrator #inkscape #photoshop #releases #religious #svg

New artwork: The Night Shall Not Be Darkened. On this one I used an erosion filter along with turbulence and displacement; the effect is most clear on the two vertical lines.


Reply via email or via office hours

#3d #art #generative-art #svg

Playing around with generative orthogonal cubes, just for fun (which probably means I’m avoiding my actual schoolwork, now that I think about it):

cubes.jpg

I wrote a Python script to generate the cubes as SVG polygons and then went through my usual filter/texture routine.


Reply via email or via office hours

#art #illustrator #inkscape #photoshop #releases #religious #svg

A few other new pieces: Nothing Shall Be Impossible unto You (about faith), Roll Forth (about the stone cut out of the mountain without hands), and Out of the Dust (about the Book of Mormon).

For a while I’ve wanted to explore using black and white for my art. Tell Me the Stories of Jesus was the initial step in that direction, but these latest four pieces are more like what I envisioned (a little more like ink on paper, to some degree). I’m looking forward to doing more work in this style.


Reply via email or via office hours