Tuesday, March 20, 2012

Patterns, Part 4

There are some patterns that just can't fit together without some kind of grammar: patterns in how the pieces interrelate. Like grammar in language, this usually means a set of rules. And this is the way most patterns work in the real world: patterns in the interaction of people, patterns in code, patterns in mathematical rules and groups, patterns in messages. We will examine a simple grammar: the even-odd grammar, and also a much more complex grammar, with a larger set of rules.

The even-odd grammar is an easy one: imagine a checkerboard. There is one rule for the black squares, and a second rule for the white squares. Let's look at a few examples.

even
odd
The first pattern, shown above, is not obviously an even-odd pattern. But its rule set says that in even squares, we must choose from the left basis set. These have a common trait. The yellow is in the upper left and the orange is in the lower right. The priority of the elements is the other aspect, and that's what makes for two elements in the even basis. In the odd basis (right) the common trait is that orange is in the upper right and yellow is in the lower left. And they have their own priority. This set was actually an image hose in Painter originally. But here I have dissected it further and given it a grammar.

Now, we mentioned a checkerboard, which is also a pattern. This has an even rule consisting only of a black square and an odd rule consisting of only a white square. But all checkerboard-like patterns can be represented this way, for example this one.

Yes, this looks like the pattern used on non-slip metallic surfaces. You see it in industry and it is quite familiar. Like the plainweave pattern, it has a horizontal and a vertical symmetry about it, like the weft and the warp of a weaving.

The basis set for this is quite simple and ingenious.

even
odd
The even basis set consists of one image: the horizontal line. Because the lines intrude into the other square, you can see the ends of the vertical line in the horizontal piece. The odd basis set is similar, but rotated 90 degrees.

This illustrates the simplest form of even-odd pattern grammar, like the checkerboard but a little more interesting.

Now we are going to go a bit loopy. We can modify a simple plainweave grammar to include loops and such. You can see that the crossings behave in a completely entangled even-odd way, and this is enforced by the grammar we used to construct it.

My pattern program can generate these in a random fashion, but I can also draw them, using the grammar to enforce the placement of elements from my brush.

In this case, I carefully drew this one to avoid small loops and to include some knots. I was going for a particular aesthetic.

I just love loops and knots. There is a kind of secret language to them. And I guess this is what I am revealing here!

even
odd
The basis set for this contains the plainweave basis set as a subset. Then I have included some elements from my curved grammar. The common aspect to each element is that the lines meet at the center of the square edges and they all have a direction that, at the edge, becomes horizontal or vertical (orthogonal).

Just to show that we can create branching and tree-like patterns with an even-odd grammar, I have included this example. Unfortunately there are some cycles in it as well. But, all in all, a complex branching pattern exists that can branch in any direction.

Like the loopy pattern, this one has an aspect of visual complexity to it.

First, it's totally not obvious (to me) that it can be constructed from a pattern basis set. I discovered this one while playing with rendered pattern elements in my patterns application. This particular rendering is totally random.

even
odd
The basis elements are appallingly simple. They are T's. The even set has horizontal crossing and either an upwards or a downwards branch. The odd set is a 90-degree rotation of the even set, with a vertical crossing and either a leftwards or a rightwards branch. It's actually kind of clean the way it's constructed!

This pattern was one of the image hoses included with Painter 3 when it shipped. But with Use Brush Grid gone from the nozzles palette, this can't be done any more. Sad, actually.

I will leave it to you to figure out how it can be constructed as an even-odd grammar. There are two basis squares per rule, and two rules, one for even and one for odd.

This one is called the knobby pattern, by the way. It does contain some dots, and also some circular holes.

You might have noticed that there is a 45-degree tilt to many patterns that you can make with the even-odd rule. And a checkerboard becomes a regular lattice in some ways when you turn it 45 degrees.

Now let's turn to a more complex grammar. I had an idea that a lattice with square holes cut out of it in 3D could be a pattern.

Here is an example of the principle in action. You can see the square lattice and the holes cut out. Once they are cut out, the sides need to have dimension lines, giving them faux depth.

Once I drew this, I realized that there were several cases and the grammar would be complicated. In all, I counted eight possible shaded square cases, including the entirely inside and entirely outside squares. So let's look at how the elements are encoded as they are placed on a regular grid.

We can see that, to get the shaded look, we will have to tag a number to each case and allow them to be placed in a geometrically reasonable configuration.

So the real question becomes: what elements exist and what is the possible set of connections between the elements?

This means we will have to enumerate all the possible elements (8 elements as it turned out) and also enumerate all the ways the elements fit together. Of course, this turned out to be a time-consuming process. And, when it was implemented in patterns, it had a few bugs. But I am good at finding and fixing bugs in logic, fortunately!

Here you see the eight elements in schematic form and the connection diagrams that form the grammar that controls the placement and configuration of the elements.

Element 0 is the entirely inside square, and element 7 is the entirely outside square. I have used the same convention as the earlier diagram.

The left table shows what configurations are legal vertically, and the right table shows what configurations are legal horizontally.

There probably should be more obvious symmetry to the table, which might be had by reordering the numbering of the elements. But this grammar does work.

You can see a rendering from the patterns application, generated entirely by random placement and adhering to the grammar as advertised.

It definitely can achieve the proper appearance, which looks like an orthogonal shaded view of blocks with shading. Perhaps like a shaded bitmap.

So pattern grammars can be molded to solve real problems in configuration and generate looks that are interesting to our eyes.

But I have only scratched the surface, really.




2 comments:

  1. Are you too old to participate in the Beyblade match but somehow still want to feel the excitement of playing Beyblade games? So this Beyblade burst mod apk is created just to cater to your interest. In this game, you can get to create and customize your own spinning tops and also fight with your friends online from 90 countries in the world. You gradually get the opportunity to move to prestigious positions after performing well.


    https://clickmodapk.com/beyblade-burst-mod-apk/

    ReplyDelete