DEV Community

Discussion on: Speed Needs Design, or: You can’t delight users you’ve annoyed

Collapse
 
philw_ profile image
Phil Wolstenholme

I wanted to use shape-outside to flow text into the empty spaces of non-rectangular products, so I could make the image larger. (I had a burning desire to maximize how many onscreen pixels could be image pixels without sacrificing too much information density.) I might post how to do this, someday.

This sounds intriguing! Thank you for another very interesting (and fun to read!) post

Collapse
 
tigt profile image
Taylor Hunt • Edited

It’s like using shape-outside: url(…), but without needing the image to load — the idea was to inline style="shape-outside:polygon(…)" along the width and height attributes to avoid layout shift.

The steps without involving code are:

  1. Resize image to 100×100 pixels
  2. Run a concave-hull algorithm on the image to get the points of the polygon
  3. Convert to CSS polygon(x1% y1%, … x𝑁% y𝑁%)
  4. Stash that wherever you store the image’s URL so you can load them all at the same time