(Undo revision 138382 by Jvvg (talk))
(Undo revision 138381 by Jvvg (talk))
Line 1: Line 1:
This tutorial will help you draw shapes using the [[pen]] using [[Procedures|custom blocks]].
+
This tutorial will help you draw shapes using the [[pen]].
 
==Square==
 
==Square==
 
A square is very easy to draw. Use this [[custom Block|custom]] [[block]]:
 
A square is very easy to draw. Use this [[custom Block|custom]] [[block]]:
 
<scratchblocks>
 
<scratchblocks>
define square (side length)
+
define square (size)
 
repeat (4)
 
repeat (4)
change x by (side length)
+
move (size) steps
change y by ((-1) * (side length))
+
turn cw (90) degrees
change x by ((-1) * (side length))
 
change y by (side length)
 
 
end
 
end
 
</scratchblocks>
 
</scratchblocks>
The chosen [[sprite]] will now draw a square when you run the block, starting with its original location as the top-right corner.
+
Your [[sprite]] will now draw a square when you run the block.
 
==Rectangle==
 
==Rectangle==
 
A rectangle is only slightly harder to draw. Use this block:
 
A rectangle is only slightly harder to draw. Use this block:
 
<scratchblocks>
 
<scratchblocks>
 
define rectangle height (height) width (width)
 
define rectangle height (height) width (width)
change x by (width)
+
repeat (2)
change y by ((-1) * (height))
+
move (width) steps
change x by ((-1) * (width))
+
turn cw (90) degrees
change y by (height)
+
move (height) steps
 +
turn cw (90) degrees
 +
end
 
</scratchblocks>
 
</scratchblocks>
Your sprite will now draw a rectangle when you run the block, starting with the current location as the top right corner.
+
Your sprite will now draw a rectangle when you run the block.
 
==Circle==
 
==Circle==
 
A circle is is slightly harder to draw than a rectangle. Use this block:
 
A circle is is slightly harder to draw than a rectangle. Use this block:

Revision as of 01:18, 20 January 2016

This tutorial will help you draw shapes using the pen.

Square

A square is very easy to draw. Use this custom block:

define square (size)
repeat (4)
move (size) steps
turn cw (90) degrees
end

Your sprite will now draw a square when you run the block.

Rectangle

A rectangle is only slightly harder to draw. Use this block:

define rectangle height (height) width (width)
repeat (2)
move (width) steps
turn cw (90) degrees
move (height) steps
turn cw (90) degrees
end

Your sprite will now draw a rectangle when you run the block.

Circle

A circle is is slightly harder to draw than a rectangle. Use this block:

define circle (size)
repeat (round ((360)/(size)))
move (size) steps
turn cw (size) degrees
end

Your sprite will now draw a circle when you run the block.