0% found this document useful (0 votes)
370 views22 pages

Mandala

This document provides instructions for creating a computer-generated mandala using the Scratch programming environment. It involves using clones and my blocks to create repeating patterns and optimize the code. Parameters are added to the my blocks to control properties like size, position and rotation. Multiple pattern calls are stacked to build up the full mandala design. A setup block is created to initialize the sprite properties. Finally, color is added by changing the sprite costume and color effect when clicked.

Uploaded by

api-652369770
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
370 views22 pages

Mandala

This document provides instructions for creating a computer-generated mandala using the Scratch programming environment. It involves using clones and my blocks to create repeating patterns and optimize the code. Parameters are added to the my blocks to control properties like size, position and rotation. Multiple pattern calls are stacked to build up the full mandala design. A setup block is created to initialize the sprite properties. Finally, color is added by changing the sprite costume and color effect when clicked.

Uploaded by

api-652369770
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Projects

Mandala
Make computer generated mandalas in Scratch

Step 1 You will make

Create a program that generates mandalas.

Computer generated art or digital art is simply art that is made using a computer. It can range from drawings created on a tablet, to
writing Artificial Intelligence (AI) programs to enable a computer to create its own art. In this project, you are going to use programming
in Scratch to create mindful artwork.

Mandala is a Sanskrit word that roughly means “circle”. Manadalas are commonly circular designs that have repeating colours, shapes,
and patterns. In Buddhist and Hindu traditions, mandalas are helpful in meditation. Creating mandalas is known to be a relaxing and
mindful activity.

You will:

Use clones to create repeating patterns


Use My Blocks to optimise your computer generated art program
Use addition + and subtraction - operator blocks to change the appearance and position of a sprite
Step 2 Clone shapes to make a pattern

Clone sprites to create a pattern.

Open the Scratch starter project (https://scratch.mit.edu/projects/540476254/). Scratch will open in another browser tab.
If you are working offline, you can download the starter project (https://scratch.mit.edu/projects/540476254/).

You should see a shape sprite that looks a bit like a flower petal.
You will use my blocks to create a pattern with this shape. You may remember creating my blocks to organise your code in Nature
Rover (https://projects.raspberrypi.org/en/projects/nature-rover/3), and to repeat the same code in Puzzle Room (https://projects.r
aspberrypi.org/en/projects/puzzle-room/4). My blocks can also be used to reuse actions in a different way.

Go to My Blocks and name your blocks (we have called it pattern:). Add repeat as a label to identify the first input or what
programmer call a parameter. Then click “Add an Input” to actually create the parameter called repeat.

define pattern: repeat repeat

To design how a pattern is made, the first step is to define pattern.


Drag the repeat parameter from define pattern into a repeat loop block.

define pattern: repeat repeat

repeat repeat

You will now use clone blocks to make the same block appear a number of times. Make sure you also add code to change the size and
position of the sprite, otherwise the sprites will be stacked on top of each other and you will not be able to see them.

Add some code into the repeat loop of your pattern.

define pattern: repeat repeat

repeat repeat

change size by 10 So you can see the clones

move 5 steps So you can see the clones

create clone of myself

Tip: Defining makes a general pattern outline. What you are creating now with my blocks is similar to creating a spirograph stencil; it is the
tool and the pattern is later created by using it.
Create a pattern with your my blocks. Get the pattern to repeat a number of times when flag clicked.

when clicked

show Shape is displayed

set size to 50 % Not too big

go to x: 0 y: 0 Displayed in the middle

pattern: repeat 3

Test: See what your pattern looks like by clicking the green flag to run your program.

You should see the beginning of a mandala pattern. Adding more parameters, or requirements, to your pattern will create the first part of
your mandala.

Save your project


Step 3 Make a mandala

Create more patterns to make a mandala!

Right click on your define pattern block and choose Edit to add more parameters.

You can start by adding a size text label and a size input. Then, add a move label and input, and use these parameters in the
blocks below.

define pattern: repeat repeat size size move move

repeat repeat

change size by size

move move steps

create clone of myself

when clicked

pattern: repeat 3 size 10 move 5

Test: See what your pattern looks like by clicking the green flag to run your program. It doesn’t look like a mandala yet! Can you
think of how you might make the pattern circular?

To make your pattern circular and look even more like a mandala, add another input.
Add another input called turn. Then, as well as moving your clone, you can turn it as well.

define pattern: repeat repeat size size move move turn turn

repeat repeat

change size by size

move move steps

create clone of myself

change size by 0 - size

move 0 - move steps

turn turn degrees

move move steps

create clone of myself

move 0 - move steps

turn turn degrees

Mandalas are often complex — they can have many different rows that follow similar patterns. You can create a base pattern for the rest of
the mandala rows to build on.

Try playing around with different numbers in your pattern. You can reset the position and size of your sprite anytime you like.

when clicked

pattern repeat 3 size 0 move 0 turn 60


Now that you have a basic pattern, you can use your pattern a number of times to make a repeating pattern, or mandala ‘rows’. By using
the same code over and over again, you make a program that has been optimised.

Optimisation means doing things in the most efficient way. Look at the diagram below. You could get from A to E by following the path
A–>B–>C–>D–>E. An optimisation would be to go A–>D–>E, which contains fewer steps and a shorter distance.

Beneath your when flag clicked block, add in a few more calls to your pattern.

when clicked

pattern repeat 3 size 0 move 0 turn 60

pattern repeat 6 size 10 move 45 turn 30

pattern repeat 6 size 10 move 90 turn 30

Test: Click the green flag, and see what pattern is produced. You can change the numbers to experiment with patterns that you
like, or even add in more calls to your pattern.

Save your project


Step 4 Set up your sprite

Set up your sprite to reset your mandala.

At the moment, your mandala patterns may appear to change each time, depending on the parameter values you use. Next, you will create a
new my blocks, so that your mandala sprite always begins in the same state.

Use the My Blocks menu to create a new block called setup. The block should have four parameters: size, ghost, y, and
move. Don’t worry, you can change these or add more later.

define setup: size size ghost ghost y y move move

When you make the mandala colourful in the next step, the ghost block will make the colours transparent so when the shapes overlap, you
will get a colour mixing effect.

Now add some blocks to set the appearance and position of your sprite.

define setup: size size ghost ghost y y move move

set size to size %

set ghost effect to ghost

go to x: 0 y: 0

point in direction 90

change y by y position

move move steps


At the moment, your my blocks hasn’t been used, so there will be no effect on your pattern. Add code to setup, so the code will
run as soon as the flag is clicked.

when clicked

setup: size 60 ghost 50 y 10 move 10

pattern: repeat 3 size 10 move 5 turn 60

pattern: repeat 5 size 10 move 45 turn 30

pattern: repeat 6 size 10 move 90 turn 30

Test your code by clicking on the flag and observing the pattern that has been drawn. Then, change the values of the parameters
until you have a pattern that you like.

The sprite (not its clones) is still visible; it can be hidden at the end, but will need to be shown at the start.

when clicked

show

setup: size 60 ghost 50 y 10 move 10

pattern: repeat 3 size 10 move 5 turn 60

pattern: repeat 5 size 10 move 45 turn 30

pattern: repeat 6 size 10 move 90 turn 30

hide

Save your project


Step 5 Mandala colouring

Adding colour to a mandala is therapeutic as well as a creative activity. Add in the


opportunity to colour different parts of the mandalas.

Tip: If you want to, you can print out your mandala before you add colour to it in this step, and use it as a colouring pattern to colour by hand.

Have a look at the current costumes for your shape sprite. You will see that there are two costumes, one white and the other filled
in.

To add colour to your mandala, each of the clone shapes should change its costume and then its color effect when the clone is clicked.
The new costume will be one more than whatever the previous costume was, so it will change to the coloured version and then to the
different colours.

Add a when this sprite clicked block, and then use the + operator to change the costume number.

when this sprite clicked

switch costume to answer + 1


Add a change color effect block to this script, so that each time the sprite is clicked, the colour changes a little.

when this sprite clicked

switch costume to answer + 1

change color effect by 25

You might remember adding a ghost block input to your project in the last step. You should now be able to see what happens when you
change the number where you call ghost.

Create the kind of colouring effect you want by changing your ghost numbers. A lower ghost number will mean the colour is
more saturated, like a permanent marker. A high ghost number will mean the colour is less saturated, like watercolours.

Test: Click the flag, choose your costume, and then try clicking on the clones to change their colours.

You should get a kaleidoscope effect when colours are layered on top of each other.

If you like the mandala you have created then you can right-click on the stage, and choose to save the image.
Save your project
Step 6 Create another mandala

Create another mandala easily using your optimised code blocks.

You have two costumes that you are using to create your coloured mandala. Add some more costumes to personalise your mandala even
more.

Choose: Add another costume. Here the Earth costume has been chosen.

It doesn’t matter which costume you pick, but you should make sure that it is a Vector costume and not a Bitmap costume. You
can tell you have chosen a Vector costume, as you will see a button labelled Convert to Bitmap. Do not click this button. If you
have selected a costume that is a Bitmap, then delete it and choose another one.
Remove all the colour from the costume so you get just the outline. Select the whole costume and change the Fill Saturation to 0
and the Outline Brightness to 0.

Duplicate this costume, and then repeat the process, this time changing the Fill colour to a dark colour of your choice.
Repeat this process a few more times with different vector costumes, to give yourself different styles of costume.

To make sure you can colour your personalised mandalas, reorder your costumes and check the costume switches to the right number.

Reorder your costumes, so that all the ones filled with white are at the top, and the ones filled with colours are lower down, but still
in the same order.

Remember to change which costume the mandala switches to so that you can colour your new mandalas. In the example project, there are
four mandalas so we changed the costume number from ‘1’ to ‘4’
when this sprite clicked

switch costume to answer + 4

change color effect by 25

Test: Switch to one of your new costumes and click the green flag to see the pattern that is generated.

Save your project


Step 7 Choose your mandala

Everyone is different. Give the person using your mandala program a choice based on
what they find most peaceful.

You should now have at least two different mandalas. You can use an ask block to create a start menu, giving a choice to whoever is using
your mandala program.

Start menus are often found in games and apps. They let the person playing the game or using the app pick from a number of options,
for example, what character they want to play, or what settings they want.

Create the question you will ask in your start menu.

Add an ask and wait block beneath the when flag clicked and choose the text for your question, like the example below.

when clicked

hide

ask What feels most peaceful to you today? (1) abstract shapes (2) the earth (3) butterflies (4) love and wait

show

setup: size 60 ghost 50 y 10 move 10

pattern: repeat 3 size 10 move 5 turn 60

pattern: repeat 5 size 10 move 45 turn 30

pattern: repeat 6 size 10 move 90 turn 30

hide

The reason for hiding the sprite before using the ask and wait is so that the question appears at the bottom of the stage, rather than as a
speech bubble from the sprite.
Match the answer with the right sprite to show the right mandala.

Add a switch costume to answer block underneath the ask and wait block.

when clicked

hide

ask What feels most peaceful to you today? (1) abstract shapes (2) the earth (3) butterflies (4) love and wait

switch costume to answer

show

setup: 60 50 10 10

pattern: 3 10 5 60

pattern: 5 10 45 30

pattern: 6 10 90 30

hide

Test: Try your mandala project by clicking the flag and choosing a number.

Save your project


Upgrade your project
Get your mandalas to move like a kaleidoscope.
You can add in a few blocks to have your clones move around when a key is pressed or when a sprite is clicked on for some extra relaxation.
Maybe some gentle music can play as well.

Completed project

You can view the completed project here (https://scratch.mit.edu/projects/536953224/).

Save your project


What next?
If you are following the Further Scratch (https://projects.raspberrypi.org/en/pathways/further-scratch) pathway, you can move on to
the Swarms, schools, and flocks (https://projects.raspberrypi.org/en/projects/swarms-schools-flocks) project. In this project, you will
make a game that uses clones to make a simulation of a group of animals.

If you want to have more fun exploring Scratch, then you could try out any of these projects (https://projects.raspberrypi.org/en/project
s?software%5B%5D=scratch&curriculum%5B%5D=%201).

Published by Raspberry Pi Foundation (https://www.raspberrypi.org) under a Creative Commons license (https://creativecom


mons.org/licenses/by-sa/4.0/).
View project & license on GitHub (https://github.com/RaspberryPiLearning/mandala)

You might also like