I'm Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with HTML, CSS and SVG. To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

my books

Pro CSS3 Animation book coverPro CSS3 Animation, Apress, 2013

my other blogs

Massive Head CanonMassive Head Canon: Intelligent discussion of movies, books, games, and technology.

my projects

The New DefaultsThe New Defaults — A Sass color keyword system for designers.

CSSslidyCSSslidy — an auto-generated #RWD image slider. 3.8K of JS, no JQuery.

SVG Backgrounds: Escher Tiles

The work of M.C. Escher as vector tiles

As my obsession with SVG backgrounds continues, I’ve become very interested in recreating tiles based on the work of M.C. Escher. Coincidentally, I discovered that one of the audience members at my “SVG Impossible Things with SVG” presentation in San Francisco, Jessica Parsons, has been doing work along similar lines.

The code uses the SVG <pattern> element that I’ve discussed previously; interestingly, it is to make directly in code, rather than trying to draw in Illustrator or Sketch.

Boxes on Boxes

The code for this example:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%">
<style type="text/css">
svg { background: #777; }
rect { stroke: none; }
#left { fill: #888; }
#right { fill: #666; }
</style>
<defs>
<pattern id="boxes" patternUnits="userSpaceOnUse" width="300" height="573" patternTransform="scale(.5)">
<rect width="150" height="200" transform="skewY(30)" id="left" />
<rect x="150" y="173" width="150" height="200"  transform="skewY(-30)" id="right" />
<use xlink:href="#right" transform="translate(-150, 285)" />
<use xlink:href="#left" transform="translate(150, 285)" />
</pattern>
</defs>
<rect width="100%" height="100%" fill="url(#boxes)" />
</svg>

Two things of note:

  • the background of the SVG forms the color of the “top” of each box, coloring the space between elements. (The top is not an element itself.)
  • the size of the final tiled result is controlled by adjusting the scale of the pattern.
  • the transform applied to the elements is very similar to CSS transforms; knowing one allows you to use the other.

I’ll be addressing the <use> element in a future article. See the code for this effect on CodePen

This site helps millions of visitors while remaining ad-free. For less than the price of a cup of coffee, you can help pay for bandwidth and server costs while encouraging further articles.