VeeLang Shape Naming — Your Shapes Remember! 🏷️¶
Learn how to give your shapes names and use them like magic
The Amazing Power of Names! ✨¶
You know how everything important has a name — your pet, your favorite toy, your best friend? In VeeLang, you can give names to your shapes too — and that unlocks incredible powers!
Creating a Named Circle 🎯¶
VeeLang gives you two ways to create named circles:
Method 1: Name First, Draw Later¶
// Default canvas: 800 wide, 600 tall, white
circle a at 200,200 having color "peachpuff"
draw a
Method 2: Name and Draw Together¶
// Default canvas: 800 wide, 600 tall, white
draw circle a at 200,200 having color "peachpuff"
Both methods do the same thing: they create a circle called a that VeeLang remembers, so you can use it later.
When to use which?¶
- Method 1: Create several shapes first, then draw them all later
- Method 2: Draw immediately to see your shape right away
It's like having two ways to introduce yourself — sometimes you plan what to say, sometimes you just dive right in!
Why Give Shapes Names? 🤷♀️¶
Think of it like this: - 📱 You save your friend's phone number so you can call them later - 📚 You bookmark your favorite website so you can visit it again - 🎮 You save your game progress so you can continue playing
Naming shapes works the same way! Once you name a shape, VeeLang remembers everything about it and you can use it later.
The REAL Magic: Using Named Shapes! 🪄¶
Here's where things get super exciting. Once you've named a shape, you can use its properties to help create other shapes:
// Default canvas: 800 wide, 600 tall, white
draw circle a at 200,200 having color "peachpuff"
draw circle b at a.center having radius 100
🎉 What happened here?
- Circle a is at position 200,200 with some radius (say 50)
- Circle b is drawn at the same position as circle a (using a.center)
- But circle b has radius 100 — twice as big!
Circle Properties You Can Use! 📋¶
When you name a circle, VeeLang remembers these special properties:
- center — The exact middle point
- Example:
at a.center - radius — How big the circle is
- Example:
having radius a.radius - color — Both fill and stroke colors
- Example:
having color a.color
Cool Examples to Try! 🎨¶
Example 1: Circles Inside Circles¶
// Default canvas: 800 wide, 600 tall, white
draw circle big at 300,300 having fill "lightblue", radius 80
draw circle small at big.center having fill "navy", radius 40
This creates a bullseye pattern!
Example 2: Matching Colors¶
// Default canvas: 800 wide, 600 tall, white
draw circle sun at 150,150 having color "gold", radius 60
draw circle planet at 400,300 having color sun.color, radius 30
The planet uses the same color as the sun!
Example 3: Growing Circles¶
// Default canvas: 800 wide, 600 tall, white
draw circle tiny at 200,200 having color "purple", radius 20
draw circle medium at tiny.center having color tiny.color, radius 40
draw circle large at tiny.center having color tiny.color, radius 60
Three circles, same center, same color, different sizes!
Why This is a Programming Superpower! 🦸♂️¶
- No More Repeating! — Instead of typing
200,200over and over, just usea.center. - Easy Changes! — Change circle
a's position once, and everything that usesa.centermoves automatically. - Perfect Alignment! — Want shapes perfectly lined up? Use the same reference point.
- Color Coordination! — Want matching colors? Reference the same shape's colors.
Real-World Thinking Exercise! 🧠¶
Imagine you're designing a snowman:
// Default canvas: 800 wide, 600 tall, white
draw circle head at 300,200 having fill "white", stroke "black", radius 40
draw circle body at 300,280 having color head.color, radius 60
draw circle base at 300,380 having color head.color, radius 80
Why is this awesome?
- All three circles automatically have the same colors
- If you want to move the whole snowman, just change head's position
- If you want to change the snowman's color scheme, just change the head circle!
The Dot Magic! 🔮¶
That little dot (.) in a.center is like a magic connector:
- a — "Hey VeeLang, I'm talking about circle a"
- . — "Give me this specific thing about it"
- center — "I want its center point"
It's like saying "a's center" or "the center of a" in English!
Practice Challenges! 🏆¶
- 🌟 Challenge 1: Twin Circles
- Create two circles with the same radius but different colors at different positions
- 🌟 Challenge 2: Color Echo
- Create a small circle, then create a larger circle that uses the small circle's stroke color as its fill color
- 🌟 Challenge 3: Circle Family
- Create a "parent" circle, then create three "child" circles that are all positioned at the parent's center but have different sizes
- 🌟 Challenge 4: Moving Together
- Create several circles that all reference the same "base" circle's center, so when you move the base, they all move together!
Pro Tips! 💡¶
- Good Naming — Use simple names like
a,b,sun,moon. Names should make sense to you! - Order Matters — Create (name) your shape first. Draw it second. Reference it third.
- Experiment! — Try using
big.radiusin athicknessproperty. Mix and match different shape properties. See what cool effects you can create!
What's Next? 🚀¶
You've just learned one of the most powerful features in VeeLang — shape naming and referencing! This same technique works with ALL shapes in VeeLang, not just circles.
In our next tutorial, we'll use names with rectangles. Get ready to build some amazing artwork!
Remember: Every time you name a shape, you're not just drawing — you're creating a building block that you can use to make even cooler creations! 🏗️✨