Week 2 -- beginning remarks

First of all, let me warn you that the course material will get a bit more complex and possibly difficult as the weeks progress. SVG is a big and complex specification. Our hope is to give you an exposure to some of its depth and richness. However, that depth and richness does come with the price of some complexity. In this week, as you see how paths and gradients are defined, you'll start to get a hint of how expressive the language is!

Next, let me apologize for making a rather difficult Part 3 of the assignment for Week 1. It was meant to get you thinking. In a sense, the thing you thought you saw: namely three lines interwoven with three ellipses, cannot be accomplished in SVG. Yes! It was sort of a trick assignment. My reason was to allow you to learn the lesson that stacking order is defined strictly in SVG as the order in which objects are defined in the document (or, more technically, within the Document Object Model). If A is atop B and B is atop C, then A must be atop C as well!  Let me explain and then offer a solution (there are more than one).

In the figure below, I've labeled the three ellipses (E1, E2, and E3) and the various visible parts of the rectangles (1a, 1b, 1c, 2a, 2b, 3a, 3b, and 3c). Now assuming that there are just six objects here: three ellipses and three rectangles, then we have that rectangle one is atop E2 but under E1 and E3. Rectangle 2, though (if parts 2a and 2b are part of the same object) is atop E1, and hence its stacking order in the document compels it to be atop E2!. Thus we are left with the conclusion that this picture cannot be drawn in SVG using only six objects! It would take three dimensions as well as curvature of the objects in three space to create such a figure, and SVG is not a three-dimensional environment (though there has been plenty of talk within the community about 2.5 dimensional effects -- or the simulation of 3 dimensional appearances, and SVG 2.0 will likely have a smattering of such capabilities). In fact, if you look closely at the edges where E2 intersects 2a and 2b, you might be able to see that the edge of E2 looks a little thinner there. That is because

Part 3 of Week 1's assignment appearing to show three ellipses interwoven with three rectangles

So, how then might we do this? Well, how about this approach: we'll lay down E2 first, at the bottom of the stacking order. On top of that we'll put rectangles 1 and 3. On top of those we'll next add E1 and E3. This gives us the diagram below at left. Next, atop E1 and E3, we'll add TWO rectangles (2a and 2b) as shown below, right. The only task now is to adjust the right edge of 2a, and the left edge of 2b (and the width of both), so as to complete the illusion.

One ellipse under two rectangles and two more ellipsesAdding two more rectangles atop it all

Here's the actual code I used to generate this nasty exercise:

It serves as a warning, perhaps, that some of the exercises may involve thinking outside the loom.