# Project: SigilPen ## What It Does

Constructing sigils from magic squares or other ciphers (e.g., the Rose-Cross) is an early form of generative or algorithmic art. SigilPen automatically generates sigils from words or phrases such as statements of intent, using the magic squares corresponding to the seven Hellenistic planets. You may press the number keys 1–7 to change the magic square used to generate the sigil: 1=Saturn; 2=Jupiter; 3=Mars; 4=Sol; 5=Venus; 6=Mercury; 7=Luna. You can press the space key to input new text.

Sigils generated with SigilPen may be employed in any project involving sigils, either by saving the drawing as-is (right-click on the stage and select save picture of stage), or redrawing the sigil in the Scratch paint editor or other drawing application.

## How It Works

There are many ways to go about doing what SigilPen does. The basic steps SigilPen takes to generate a sigil are:

1. Get the word or phrase to sigilize.
2. Remove all numbers, punctuation, spaces, and duplicate letters from the inputted text.
3. Convert each letter in the remaining text string to a number (stored in a variable named `cipher`) according to the scheme:

1 2 3 4 5 6 7 8 9
-----------------
A B C D E F G H I
J K L M N O P Q R
S T U V W X Y Z

4. Move to each pair of Cartesian coordinates corresponding to where each number appears on the selected planetary square, drawing lines between the points.

Scratch’s pen feature draws the lines. The pairs of coordinates are actually all stored in a single list (named `positions`). This is possible because there are exactly nine x positions and nine y positions for each square, and only seven squares, so the list is constructed thus:

[…]
`10. SATURN_X`
`11. 0` ← the x position of ‘1’ in Saturn’s square
`12. 35` ← the x position of ‘2’ in Saturn’s square
`13. -35` ← &c.
`14. -35`
`15. 0`
`16. 35`
`17. 35`
`18. -35`
`19. 0` ← the x position of ‘9’ in Saturn’s square
`20. JUPITER_X`
`21. 53` ← the x position of ‘1’ in Jupiter’s square
`22. -18` ← the x position of ‘2’ in Jupiter’s square
`23. 18` ← &c.
`24. -53`
`25. -53`
`26. 18`
`27. -18`
`28. 53`
`29. -53`
[…]
`110. SATURN_Y`
`111. -35` ← the y position of ‘1’ in Saturn’s square
`112. 35` ← the y position of ‘2’ in Saturn’s square
`113. 0` ← &c.
`114. 35`
`115. 0`
`116. -35`
`117. 0`
`118. -35`
`119. 35`
`120. JUPITER_Y`
`121. 53` ← the y position of ‘1’ in Jupiter’s square
`122. -53` ← the y position of ‘2’ in Jupiter’s square
`123. -53` ← &c.
`124. 53`
`125. -18`
`126. 18`
`127. 18`
`128. -18`
`129. 18`
[…]

The x position for any number 1–9 of any magic square may be found by multiplying the number of the planet times 10 and adding the number, and the y position can be found by adding 100 to that sum. E.g., to find the location of number 4 in the square of Jupiter:

1. Multiply the number of the planet Jupiter, 2, times 10, and add 4: 24 is the item number in the `positions` list where the x coordinate is stored.
2. Add 100 to 24: 124 is the item number in the `positions` list where the y coordinate is stored.
3. The screen location of the number 4 in the square of Jupiter is: −53, 53. It may sound convoluted but it lets us go to any position within any square by using just one block: (Since the `planet` variable does not change within the scope of the repeat () loop, it would actually be slightly more efficient to calculate `planet` * 10 and `planet` * 10 + 100 just before executing the loop, but it would require two new variables to store the results in.)

`SigilPen` stamps a circle costume in the square where the sigil begins, and a short line costume in the square where it ends. The custom block point toward x: () y: () (source) orients `SigilPen` in relation to the penultimate vertex in the sigil, in order to draw the short terminal line perpendicular to the final line drawn in the sigil.

## Make It Better

• You can save the current drawing by right-clicking on the stage and selecting save picture of stage. Edit the project so you may select a blank background before saving the drawing.
• Add controls that allow you to change the pen color (hint).
• `SigilPen` includes a `numberFreq` list that tracks how many times a given square is used as a vertex. E.g., if a sigil includes both letters ‘A’ and ‘J’, the number ‘1’ square is used twice. Can you edit `SigilPen` to draw something unique in squares that are hit more than once? N.b., since duplicate letters are removed from the input text, the maximum number of times any square can be a vertex is three (for number 9, the max is two).
• You can use the glide () secs to x: () y: () block to slow down the sigil drawing animation to appear more uncanny.