• Home
  • /
  • Blog
  • /
  • Learn To Create Line Patterns in Scratch Using 2D Shapes

Learn To Create Line Patterns in Scratch Using 2D Shapes

Create Line Patterns in Scratch

This post is also available in: हिन्दी (Hindi) العربية (Arabic)

You can create wonderful designs and pattern in Scratch using Pen blocks. In this article you will learn to create line patterns in Scratch.

What is a Shape in Geometry?

In geometry, a shape can be defined as the form of an object or its outline, outer boundary, or outer surface. These shapes are of two types – two-dimensional (2D) or three-dimensional (3D).

A 2D shape has only two dimensions – length and width, whereas a 3-D shape has three dimensions – length, width, and height.

Examples of 2D shapes are square, rectangle, triangle, circle, pentagon, etc.

Create Line Patterns in Scratch
2D Shapes

And the examples of 3D shapes are cube, cuboid, sphere, cylinder, cone, pyramid, prism, etc.

Create Line Patterns in Scratch
3D Shapes

What is a Pattern?

A pattern is a repeated design or a recurring sequence of an ordered set of numbers, shapes or other mathematical objects, arranged according to some rule. 

A number pattern is a sequence that follows a certain sequence or pattern. Some of following number patterns are:

1, 4, 7, 10, 13, 16, … starts at 1 and jumps 3 every time.

1, 4, 9, 16, 25, 36, … starts with 12, followed by 22, 32, and so on.

A geometric pattern is a kind of sequence formed of geometric shapes and typically repeated like a wallpaper design. Some of the examples of the geometric pattern are:

Create Line Patterns in Scratch
Geometric Patterns

Creating Geometric Patterns in Scratch

You can make use of the ‘Pen’ tool in Scratch to create amazing geometric patterns. The first step in creating these patterns is that two basic knowledge are required 

  • drawing 2D figures such as square, rectangle, triangle, circle, pentagon, etc.
  • looping i.e., the repeat block for repetition of 2D figures.

With the ‘Pen’ extension, coding to draw a shape is very simple with some basic knowledge of geometry. Furthermore, amazingly complex patterns can be constructed with just a few colourful blocks of code. With the pen tool, the possibilities are immense and incredibly exciting. With your imagination coupled with your creativity, the patterns you can come up with are simply enormous.

Patterns With Straight Line

A straight line can be drawn in the following four ways – horizontal line, vertical line, left slanting line and right slanting line.

Create Line Patterns in Scratch
Types of Lines

Drawing a Horizontal Line

To draw a horizontal line of length 200 units from a point (x1, y1), first of all, place the sprite at the position (x1, y1) and then point the sprite in the direction 90 and then move 200 steps.

Create Line Patterns in Scratch
Horizontal Line

Drawing a Vertical Line

To draw a vertical line of length 200 units from a point (x1, y1), first of all, place the sprite at the position (x1, y1) and then point the sprite in the direction 90 and then turn 90 degrees and finally move 200 steps.

Create Line Patterns in Scratch
Vertical Line

Drawing a Left Slanting Line

To draw a left-slanting line of length 200 units from a point (x1, y1), first of all, place the sprite at the position (x1, y1) and then point the sprite in the direction 90 and then turn 45 degrees (angle depends on the inclination of slanting line with the horizontal) and finally move 200 steps.

Create Line Patterns in Scratch
Left-Slanting Line

Note that when the angle of rotation is positive, then the line drawn is left slanted.

Drawing a Right Slanting Line

To draw a right-slanting line of length 200 units from a point (x1, y1), first of all, place the sprite at the position (x1, y1) and then point the sprite in the direction 90 and then turn -45 degrees (angle depends on the inclination of slanting line with the horizontal) and finally move 200 steps.

Create Line Patterns in Scratch
Right-Slanting Line

Note that when the angle of rotation is negative, then the line drawn is right slanted.

Now, let’s draw the basic unit of a snowflake as shown in the figure below.

Create Line Patterns in Scratch
Basic unit of snowflake

Now, it’s time to draw a complete snowflake. To do so, repeat the above code 6 times (using repeat block) and after each step turn 60 degrees (6 × 60 = 360 degrees, will complete one circle).

Create Line Patterns in Scratch
Snowflake

Note that 150 steps is changed to 120 steps and 50 steps changed to 40 steps, just to fit it best on the stage.

Now, you can repeat the above code to draw a pattern consisting of snowflakes. In the following, the above code is repeated 10 times and after each iteration the centre point of the next snowflake is moved 40 steps ahead.

Create Line Patterns in Scratch
Pattern with snowflakes

Let’s now draw colourful snowflakes.

Create Line Patterns in Scratch
Colourful snowflakes pattern

The following code will draw the above pattern:

Create Line Patterns in Scratch
Colourful snowflakes pattern code

Some More Patterns Using Lines

Rainbow Pattern

Rainbow pattern consisting of different coloured lines can be drawn by drawing a straight line and repeating the process by changing the direction and colour of the line.

Create Line Patterns in Scratch
Rainbow pattern

Floral Pattern

Create Line Patterns in Scratch
Floral pattern

Let’s first see how to draw a single unit (leaf) of the above pattern.

Create Line Patterns in Scratch
A leaf

Now, repeat the above code 12 times to get a floral pattern.

Create Line Patterns in Scratch
Floral pattern code

You can further enhance the code to draw a colourful pattern of the above floral design, by repeating the above code 10 times and changing the direction by 36 degrees after each iteration. (10 × 36 = 360 degrees, a complete circle).

Create Line Patterns in Scratch
Colourful floral pattern

Can you try some more similar patterns and designs? And don’t forget to share with us!

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>