# Aligning elements

**URL:** https://forum.algorithmicpattern.org/t/aligning-elements/492
**Category:** Discussion
**Created:** [24 July 2022 22:19 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492 "2022-07-24T22:19:32Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![yaxu](https://forum.algorithmicpattern.org/user_avatar/forum.algorithmicpattern.org/yaxu/32/3_2.png) [@yaxu](https://forum.algorithmicpattern.org/u/yaxu)
#### Post date: [24 July 2022 22:19 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/1 "2022-07-24T22:19:32Z")

</div>

I’ve been thinking about the different ways of aligning sequences in music, trying to list the possibilities. For example with the three sequences `a b`, `1 2 3` and `w x y z`:

Flush left:

```plaintext
a b
1 2 3
w x y z

```

Flush right:

```plaintext
    a b
  1 2 3
w x y z

```

Truncate on the right at shortest:

```plaintext
a b
1 2
w x

```

Truncate on the left at shortest:

```plaintext
a b
2 3
y z

```

Truncate at longest, repeating:

```plaintext
a b a b
1 2 3 1
w x y z

```

Repeat to first common multiple (polymeter):

```plaintext
a b a b a b a b a b a b 
1 2 3 1 2 3 1 2 3 1 2 3
w x y z w x y z w x y z

```

Centre

```plaintext
  a b
 1 2 3
w x y z

```

Pad:

```plaintext
a b
1 2 3
w x y z

```

I also thought about variants within these, based on e.g. whether the items are padded with ‘silence’ or stretched to fill the space. For example if we do this with ‘pad’, we get classic musical polyrhythms:

```plaintext
a-----b-----
1---2---3---
w--x--y--z--

```

Also the above examples assume the three sequences are played at the same time (i.e., stacked up with the a horizontal time dimension going to the right). They could alternatively be concatenated to create monophonic sequences, though.

I’d bet that this is well explored territory in e.g. typography for example (centred, justified text etc), but I don’t know much about that. Does someone have some typographic or other references for this sort of thing that they could share?

---

<div class="post-metadata">

### Author: ![bwagner](https://forum.algorithmicpattern.org/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bwagner](https://forum.algorithmicpattern.org/u/bwagner)
#### Post date: [25 July 2022 10:34 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/2 "2022-07-25T10:34:12Z")

</div>

Donald Knuth’s TeXbook might be a good reference for text layout algorithms:

> **[Computers and Typesetting](https://en.wikipedia.org/wiki/Computers_and_Typesetting)**
>
> Computers and Typesetting is a 5-volume set of books by Donald Knuth published in 1986 describing the TeX and Metafont systems for digital typography. Knuth's computers and typesetting project was the result of his frustration with the lack of decent software for the typesetting of mathematical and technical documents. The results of this project include TeX for typesetting, Metafont for font construction and the Computer Modern typefaces that are the default fonts used by TeX. In the series o...

---

<div class="post-metadata">

### Author: ![totalgee](https://forum.algorithmicpattern.org/user_avatar/forum.algorithmicpattern.org/totalgee/32/141_2.png) [@totalgee](https://forum.algorithmicpattern.org/u/totalgee)
#### Post date: [25 July 2022 11:15 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/3 "2022-07-25T11:15:39Z")

</div>

I like these examples, they all seem useful to explore musically. A relevant concept from the SuperCollider language is the notion of “adverbs” (modifiers that can be used when combining arrays, or to modify the behaviour of any binary operator). Your examples above already cover some of these possibilities, but in case you’re interested:

[http://doc.sccode.org/Reference/Adverbs.html](http://doc.sccode.org/Reference/Adverbs.html)

Glen.

---

<div class="post-metadata">

### Author: ![rdd](https://forum.algorithmicpattern.org/letter_avatar_proxy/v4/letter/r/bc79bd/32.png) [@rdd](https://forum.algorithmicpattern.org/u/rdd)
#### Post date: [25 July 2022 13:53 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/4 "2022-07-25T13:53:42Z")

</div>

Nice list!

For reference, the Sc rule not above is f (for fold):

```auto
a b a b
1 2 3 2
w x y z

```

Also, t (for table) suggests various possibilities, but all rather longer…

```auto
a b a b a b a b a b a b a b a b a b a b a b a b
1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3
w w w w w w x x x x x x y y y y y y z z z z z z

```

---

<div class="post-metadata">

### Author: ![sporb](https://forum.algorithmicpattern.org/letter_avatar_proxy/v4/letter/s/9e8a1a/32.png) [@sporb](https://forum.algorithmicpattern.org/u/sporb)
#### Post date: [25 July 2022 14:27 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/5 "2022-07-25T14:27:21Z")

</div>

Good morning;  
The ‘alignment of patterns’ makes me think of

1: fractal self-similarity

2: Christopher Alexander’s ‘A Pattern Language’ where he has meta patterns as well as core patterns.

> **[Alexander\_A\_Pattern\_Language.pdf](https://arl.human.cornell.edu/linked%20docs/Alexander_A_Pattern_Language.pdf)**
>
> 11.43 MB

{Please don’t bring up software patterns - 2 years to retirement and I upset easily ![😎](https://fonts.gstatic.com/s/e/notoemoji/14.0/1f60e/32.png))

---

<div class="post-metadata">

### Author: ![yaxu](https://forum.algorithmicpattern.org/user_avatar/forum.algorithmicpattern.org/yaxu/32/3_2.png) [@yaxu](https://forum.algorithmicpattern.org/u/yaxu)
#### Post date: [25 July 2022 14:33 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/6 "2022-07-25T14:33:08Z")

</div>

A couple of additional suggestions [from twitter](https://twitter.com/yaxu/status/1551471187175391232):

Alignment of dna that geneticists do based on similarity from @[amberfirefly](https://twitter.com/AmberFirefly/status/1551476650923233280):  
 ![image](https://forum.algorithmicpattern.org/uploads/secondsite/original/1X/8db9591785e80e4b0359d066a0c4028d5caffd3d.png)

[CSS flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) suggested by @[james\_bradbury\_](https://twitter.com/james_bradbury_/status/1551477704670724097)

![flex items within a flex container demonstrating the different spacing options](https://css-tricks.com/wp-content/uploads/2018/10/justify-content.svg)

The CSS flexbox example really was right under my nose! This makes me think about the very nice [cascade system](https://raphaelbastide.com/cascade/) by @raphael for live coding musical patterns from CSS.

---

<div class="post-metadata">

### Author: ![yaxu](https://forum.algorithmicpattern.org/user_avatar/forum.algorithmicpattern.org/yaxu/32/3_2.png) [@yaxu](https://forum.algorithmicpattern.org/u/yaxu)
#### Post date: [25 July 2022 16:03 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/7 "2022-07-25T16:03:07Z")

</div>

> [@sporb](#):
>
> The ‘alignment of patterns’ makes me think of
> 
> 1: fractal self-similarity
> 
> 2: Christopher Alexander’s ‘A Pattern Language’ where he has meta patterns as well as core patterns.

Welcome @sporb! Ah yes we’ve [discussed Alexander’s architectural patterns a little before](https://forum.algorithmicpattern.org/t/patterns-in-architecture/221), and talked a little about fractals as well, especially in the context of architecture and design within Africa and the African diaspora.

In this thread though I wanted to focus on strategies for aligning sequences in particular.

---

<div class="post-metadata">

### Author: ![yaxu](https://forum.algorithmicpattern.org/user_avatar/forum.algorithmicpattern.org/yaxu/32/3_2.png) [@yaxu](https://forum.algorithmicpattern.org/u/yaxu)
#### Post date: [25 July 2022 21:30 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/8 "2022-07-25T21:30:02Z")

</div>

I like the fold! A full cycle would be

```nohighlight
a b a b a b a b a b a b
1 2 3 2 1 2 3 2 1 2 3 2 
w x y z y x w x y z y x 

```

It could then be represented as ‘a repeat to first common multiple/polymeter’, preceded by a transformation step to create the up/down structure.

---

<div class="post-metadata">

### Author: ![yaxu](https://forum.algorithmicpattern.org/user_avatar/forum.algorithmicpattern.org/yaxu/32/3_2.png) [@yaxu](https://forum.algorithmicpattern.org/u/yaxu)
#### Post date: [25 November 2022 16:34 UTC](https://forum.algorithmicpattern.org/t/aligning-elements/492/9 "2022-11-25T16:34:51Z")

</div>

A lovely interactive explorer of this from @raphael ! [cascade/demos/start](https://raphaelbastide.com/cascade/tests/flexbox.html)
