Recipes that change, and keep to themselves 🍪
A recipe describes a kind of shape: a face, a house, a tree. Each draw makes a new one, with its own settings.
Now a recipe's shape can change its settings while things move. The recipe makes it again with the new setting, every part in the right place:
Canvas paper having width 400, length 300
shape face having size 60, skin "gold" {
circle head having radius size / 2, fill skin
circle eye1 at -size / 6, -size / 10 having radius size / 15, fill "black"
circle eye2 at size / 6, -size / 10 having radius size / 15, fill "black"
}
draw face sam at 200, 150
sam.size = 160 in 2 seconds
sam.skin = "pink" in 2 seconds
The eyes grow and move with the head, because the recipe makes the face again as size grows.
Click a recipe 👆
A click can change a setting too. Each click makes this face bigger:
Canvas paper having width 400, length 300
shape face having size 60 {
circle head having radius size / 2, fill "gold"
circle eye1 at -size / 6, -size / 10 having radius size / 15, fill "black"
circle eye2 at size / 6, -size / 10 having radius size / 15, fill "black"
}
draw face sam at 200, 150
when sam is clicked {
sam.size = sam.size + 20
}
Two new rules 📏
To make recipes work like this, they keep to themselves:
1. Only its settings change a recipe's shape. You can read its parts, like sam.eye1.center, but not change them: sam.eye1.fill = "blue" is now a mistake. Give the recipe a setting instead:
Canvas paper having width 400, length 300
shape face having size 100, eyes "black" {
circle head having radius size / 2, fill "gold"
circle eye1 at -size / 6, -size / 10 having radius size / 15, fill eyes
circle eye2 at size / 6, -size / 10 having radius size / 15, fill eyes
}
draw face sam at 200, 150
sam.eyes = "blue"
2. A recipe uses only its own settings and parts. It can't use the other shapes and numbers in your drawing. If it needs something, give it a setting, and set it where you draw it:
Canvas paper having width 400, length 300
draw circle sun at 350, 50 having radius 30, fill "gold"
shape face having size 100, skin "pink" {
circle head having radius size / 2, fill skin
}
draw face at 150, 150 having skin sun.fill
Why? A recipe should work the same way in every drawing you put it in. Everything it needs comes in through its settings, and only its settings change it. That's what makes a recipe easy to share, and soon, to keep in a file of its own.
If one of your drawings did one of these, VeeLang will tell you, with what to write instead.
Learn more in Your Own Shapes and the recipes reference. Have fun! ✨