Dev.Opera - Follow the standards, break the rulesDev.Opera - Follow the standards, break the rules

Login

Lost password?

Sign up

users

Sign up now to post in the forums, comment on articles, submit your own articles and more.

Drawing Hilbert curves with SVG

By DesertDawg · 26 Jan, 2007

Published in: , , ,

Hilbert curves are a type of space-filling curve that can be constructed with the SVG polyline element, using a basic design and then aggregating.

I started by polylining one basic design into four sections of a graph, making the necessary adjustments to connect them up. This then becomes my main building block.

(main building block)

View the main building block.

By taking the main building block and translating, rotating and scaling, the next-larger curve can be constructed. To flip a section, a negative scale value is used. The four sections are joined by three short line segments.

(next-larger curve)

View the next-larger curve.

Then, do it again to make it bigger. If you connect the two ends at the bottom, you will have a closed curved which could be copied as an image and color filled.

(next-larger curve)

View the next-larger curve.

Working with Paths

By changing the polyline to a SVG path element and connecting up the four lines, you can make a super path. Then add some SVG animated motion.

(Example 1)

View the animated path.

Here is another example of an animated path where I am animating two circles (one twice as fast as the other), one png image and one text string which only makes one circuit and then freezes.

(Example 2)

View the animated path.

Here is an example of an animated text path.

(Example 3)

View the animated text path.

digg Digg this article  del.icio.us Add to del.icio.us

Article categories