Computer-generated Floral Ornament Based on Magnetic Curves

If you are interested in purchasing the code descriped in this paper, you can do so here:


Figure 1 Examples of floral ornament: (a) 12th Cent. Illuminated Manuscript of Luke [3] (b) ILLUMINATED MANUSCRIPT LEAF ON VELLUM, by the SPANISH FORGER [4] (c) Gothic vine [5, fig. 82] (d) A band from “Purim liturgical poems: illuminated manuscript.” [6]

With the development of sophisticated printing technologies less and less documents and books were decorated by hand and with floral ornament. Along with other types of decoration it slowly became obsolete [1]. However, instead of disappearing entirely it eventually made its way into wallpaper designs of the 17th century. Figure 2a shows a wallpaper from England dating from around 1680, which is one of a few early floral wallpapers to survive to this day [7]. Typical features of floral ornament such as space-filling and repetition make a great decoration tool for for wallpaper artists, which is why it remained common throughout the 18th and 19th centuries and is even still used today (Figures 2b and 2c).

Figure 2 Floral wallpaper design: (a) Sheet of wallpaper, late 17th century [7] (b) Floral wallpaper, mid 19th century [8] (c) Modern wallpaper from Home Depot catalog [9]

While the concept of using vegetation to produce ornament seems to be very trivial to take up, it proves to be difficult to create a good floral ornament design by hand. It turns out that hand drawn floral ornamentation is a very time-consuming task that requires a great deal of skill and training. In fact, most of the floral clip-art found on the web (Figure 3) is usually produced by experienced artists and is usually quite costly. As a result, one naturally tends to think about automated ways of generate floral motifs.

Figure 3 Modern floral clip-art [10]

This article explores the problem of how to produce aesthetically pleasing computer-generated ornament. The method described here is a combination of two papers by Ling Xu et al. [11] and M. T. Wong et al. [1], which are further discussed in the next section. However, instead of of making the entire process fully automated, as aforementioned papers suggest, this article focuses on an idea of interactive user control. The vision here is that while it is possible to automatically produce a relatively attractive floral ornament, artistic input still remains the best tool for evaluation, about whether or not the resultant ornament is indeed aesthetically pleasing. Consequently, the tool that is described in this article relies on a heavy UI component.

Background Information and Related Work

In his paper Wong notes that even though floral ornaments often contain various plant-like features such as leaves, flowers and vines, the elements are often arranged in an unnatural way that is impossible for a real plant. Therefore, Wong eliminates L-system as a way to modal floral ornament and, instead, he suggests the use of adaptive clip-art. His method is based on using a set of procedural growth rules, that place pre-made clip-art elements near the largest unoccupied circles within a given region, which is then to be filled with the ornament. The algorithm described in this article adopts the idea of adaptive clip-art, but replaces the procedural growth rules with a simpler method to generate plant-like curves, which is proposed by the paper “Magnetic Curves: Curvature-Controlled Aesthetic Curves Using Magnetic Fields” [11] by Ling Xu et al.

While the results produced by Wong’s algorithm (Figure 4a) are significantly more attractive than the results of the magnetic curves method (Figure 4b), there are a number of reasons why combination of both methods is the primary focus of this article. The algorithm suggested by Wong is very complex, as it is based on the writing of non-trivial growth rules using C-preprocessor. As a result, it doesn’t provide much room for interactive control. On the other hand, Xu’s algorithm is much easier to implement and control interactively, since it’s based on set of predefined numerical parameters. Moreover, by adding the idea of adaptive clip-art the aesthetic quality of results achieved by the magnetic curves method can be significantly improved, as is demonstrated in this article.

Figure 4 Examples of the final results of related papers (a) Wong et al. [1] (b) Ling Xu et al. [9]


Starting Point

To generate the initial curve I launch a particle from the bottom center of the screen with a velocity 1px per time interval pointing straight up. I use the same function for the charge of the particle as recommended in the paper: q(t) =(T-t)^(-α). At the beginning of the curve t = 0.

Next, I generate the points of the curve using Forward Euler numerical integration with a dt value of 1. This way T is equal precisely to the number of samples for the curve. Moreover, given that the initial velocity is equal to 1px, T is also roughly equal to the length of the curve in pixels. To keep the curve smooth, I use a constant value of B over the entire space of the canvas. Overall, the algorithm used to trace a particicle can be summarized by the following psuedo code:

TRACE_PARTICLE(start_x, start_y, start_vx, start_vy, T, alpha)
x = start_x
y = start_y
vx = start_vx
vy = start_vy
t = 0
dt = 1
points = array()
while t <
Add new point [x, y] to points
q = (T - t)^(-alpha)
x = x + vx * dt
y = y + vy * dt
ax = -vy * q
ay = vx * q
vx = vx + ax * dt
vy = vy + ay * dt
return points

To release secondary particles from the parent curve the domain of t variable [0, T] can be split into N subintervals with the length T/N each. At the end of each interval a new particle can be launched, thus, producing N sub-branches. For each secondary particle we can use the position and the velocity of the parent particle as the initial conditions. However, the sign of the charge of every second launched sub-particle should flipped so that the sub-particle curves the opposite way.

Once the points of all the points’ trajectories have been generated, Catmull-Rom splines [12] can be used to interpolate them into smooth curves. The result is shown the Figure 5 below.

Figure 5 Magnetic curve growth: (a) Parent curve (b) Parent curve and its children (c) Parent curve with its children and grandchildren

Curve Levels

Furthermore, the branching algorithm in my implementation differs slightly from the one suggested in the original paper. Xu states that for any new branch a particle with the highest possible T should be chosen. Particles with lower values of T should only be selected, if particles with higher values of T intersect already generated branches. However, after studying Xu’s results, I’ve realized that this rule is the main reason why the ornament based on magnetic curves looks less natural than Wong’s results.

Looking back on a real plant, one can notice that any branch is never bigger than its parent branch. To apply this idea to my algorithm I restrict any sub-particles to have values of T no higher than its parent’s. While the restriction impacts the ability of the algorithm to produce a space-filling curve, the results end up more aesthetically pleasing.

Variable Strokes

Another component of my algorithm that is primary aimed for improving aesthetic quality of the results is an idea of variables strokes. Trunks of real plants rarely have constant girth. Instead, stems get thinner and thinner as you move away from the root. We can update the magnetic curves in a similar fashion. The base curve starts with a preset stroke width of 15 pixels at the root. As the curve grows the stroke width is decreased linearly until it is equal to zero at t = T. For each of the branching curves the initial stroke width is set equal to the stroke width of the parent curve at the start of the branch. An example is shown in Figure 6 below.

Figure 6 Variable stroke effect: (a) Curve with a constant stroke (b) Curve with a variable stroke

Without a doubt, the curve in Figure 6b looks much more plant-like than the one in Figure 6a. Moreover, the initial stroke width is another good parameter to be under user control.


One of the main advantages of Wong’s method of generating floral ornament is its superior ability to generate space-filling motifs, which are still easthetically pleasing. The reason, why the magnetic curves method is less effective at this task is because the base curve is finite and always curves only one way.

To eliminate this problem, I wish to give the user control over the base stem of the ornament. In my algorithm the user can define a set of points that the stem must go through. The stem is then generated by interpolating the points using Catmull-Rom spines. The base stem acts as the top level of the magnetic curve, thus, the remainder of the algorithm is unchanged.

Moreover, to better facilitate space filling I extend the algorithm specified in Xu’s paper to an arbitrary region. The region is defined by a set of points that can also be provided by the user of the application. To recall, Xu’s algorithm achieves space-filling by quantizing the space into cells and then assigning unique IDs to cells, which have a curve passing through them. This method turns out to be quite easy to extend to an arbitrary region by simply setting the IDs of cells that do not belong to the region to -1.

Adaptive Clip Art

Figure 7 Clip-art types: leaf, flower and bud

These elements are easily generated at runtime using a few splines, and can quickly be replaced with other elements or even with clip-art loaded from an SVG file. The only restriction is that each element must have an origin point and a direction. For instance, the leaf and the bud elements have the origin at the bottom left corner of the element. The flower has the origin at its center. All of the elements must follow a straight up direction.

An element’s origin and direction are used to place clip-art along the branches of the ornament. A new clip-art element is placed for each new launched sub-particle. The origin of the element is set at the particle’s start position, and the direction of the element is aligned with the direction of the particle’s initial velocity. Moreover, the element is reflected along the line of its direction to make it grow in the opposite direction from where the related sub-particle curves. Finally, the element is scaled according to the curve level that it is being generated for. In that sense, the clip-art is adaptive to the rest of the ornament.

The clip-art elements also participate in space-filling. Each element is assigned a unique ID at the time of creation. This ID is copied to each cell that the element intersects, when it’s placed onto the canvas. New elements are only allowed to intersect their parent curves. If no element can be placed at a certain position due to space-filling constraints, the position gets ignored.

At each level of the curve, it’s up to the user to decide which clip-art element type is used or whether no clip-art should be used at all.



  • Initial stem width (in pixels)
  • Initial curl direction (left or right)
  • Number of curve levels
  • Parameters of the curve at each level (Length/Curvature/Number of branches)
  • Clip-art element type
  • Ornament region points
  • Control points for the base step of the ornament

The demo of the application can seen in this video:

If you are interested in purchasing the code descriped in this paper, you can do so here:

Demo Images

Table 1 Parameter values for curve levels of the sample ornament

The initial stem width is set to 15 pixels and the initial curvature direction is to the right. My artistic judgement played a big part in selecting these parameter values. I believe that it’s safe to say that the final outcome is quite visually pleasing.

Figure 8 Sample floral ornament produced by the application

Figure 9 demonstrates another sample that shows an ornament base on a pre-defined base stem, which is used to decorate an arbitrary arc.

Figure 9 Floral ornament used to decorate an arc

The final example in Figure 10 show how the ornament exported in a vector SVG format can be used to produce an interesting colorful background. In this image two motifs are overlayed on top of each other.

Figure 10 Example of floral ornament usage to produce an interesting background


Conclusions and Future Work

Without a doubt, the algorithm I presented in this article greatly improves upon Ling Xu’s results from his original “magnetic curves” article. The results that I was able to achieve with my tool are comparable in their quality to a floral design that can be produced by a professional artist.

I hope that the work I’ve done here can be used one day to aid an artist in the generation of beautiful designs.

Abandoned Features

First of all, I wanted to have the ability to vary the value of B using a Poison noise function as suggested in the original “magnetic curves” paper. However, I eventually realized that adding noise to the magnetic field would make the ornament less smooth, hence, less aesthetically pleasing. As a result, this features was excluded from the implementation plan.

Furthermore, I initially wanted to make the clip-art more adaptive to its environment as suggested by Wong’s paper. For instance, each “bud” element has a small stem extending to it. It would be interesting to determine the length of this stem at run-time according to a certain set of rules. However, in the end simply adapting the clip-art elements to the direction and the size of the parent curve proved to be sufficient enough to produce good results. Hence, this feature was never implemented.

Possible Extensions

  • To produce the magnetic curves I used the same charge function as suggested in the paper. Other functions could be experimented with to produce more interesting types of curves. Xu touches upon this subject and notes that triangular waves are a good choice for experimentation.
  • One of the main problems with the magnetic curves algorithm is its ability to produce attractive space-filling curves. In this article I address this issue by requiring user input. It would be great to do it automatically. One possible way to address this issue is to make the charge function repeat with some period and make the main charged particle bounce off the edges of the ornament region. The magnetic field strength B can be increased along the region boundaries to achieve this effect. Moreover, the parameters of the charge function can be updated at runtime to facilitate space filling.
  • Some of the historical example of floral ornament that I had seen allowed an intersection between stems by arranging them into plait-work. This would be an interesting idea to experiment with.

Finally, in my algorithm I used a very simple way to place the clip-art along the curve (at equal intervals). It would be interesting to develop a more intelligent way of determining a good location to place an element, thus, making the algorithm more adaptive in nature. Moreover, using multiple types of clip-art on each level is another extension that could prove to be useful. Overall, the problem of clip-art distribution could serve a good research area in the long term.


  1. “Frame” The Grove Encyclopedia of Decorative Arts. Ed. Gordon Campbell. © Oxford University Press 2006. The Grove Encyclopedia of Decorative Arts: (e-reference edition). Oxford University Press. [Accessed April 15th, 2010]
  2. Introduction to Luke-Arts, Northwestern Church of Christ, Dec. 2008. [Online] [Accessed April 15th, 2010]
  3. Illuminated Manuscript Leaf on Vellum, Bloomsbury Auctions, Apr. 2008. [Online] [Accessed April 15th, 2010]
  4. Lewis F. Day. Nature in Ornament. B.T. Batsford, London, 1898.
  5. Judaica Collection, Yale University Library, Oct 2008. [Online] [Accessed April 15th, 2008]
  6. Sheet of wallpaper, late 17th century. Museum no. E.1003–1976, Victoria and Albert Museum. [Online] [Accessed April 15th, 2010]
  7. Floral wallpaper, about 1850–75. Museum no. E.800–1969, Victoria and Albert Museum. [Online] [Accessed April 15th, 2010]
  8. W Red, Black and Taupe Large Scale Modern Floral Wallpaper, Home Depot Catalog, Catalog #100632840, 2010.
  9. Floral Ornament Vector Pack, Ideal Hut, Oct. 2009. [Online] [Accessed April 15th, 2010]
  10. Xu L., Mould D.: Magnetic Curves: Curvature-Controlled Aeshetic Curves Using Magnetic Fields. In Computational Aesthetics in Graphics, Visualization, and Imaging (2009). pp. 1- 8.
  11. Catmull, Edwin and Rom, Raphael, A class of local interpolating splines, in R.E. Barnhill and R.F. Riesenfed (eds.) Computer Aided Geometric Design, Academic Press, New York, 1974, 317–326.

Eng Manager @Snapchat. Android hacker, and a product design geek. Previously: cofounder of @UmanoApp (acquired by @Dropbox), @Google, @Pixar, @Kik.

Eng Manager @Snapchat. Android hacker, and a product design geek. Previously: cofounder of @UmanoApp (acquired by @Dropbox), @Google, @Pixar, @Kik.