m (Square: removed vestigial repeat)
(Undo revision 138382 by Jvvg (talk))
Line 4: Line 4:
 
<scratchblocks>
 
<scratchblocks>
 
define square (side length)
 
define square (side length)
 +
repeat (4)
 
change x by (side length)
 
change x by (side length)
 
change y by ((-1) * (side length))
 
change y by ((-1) * (side length))
 
change x by ((-1) * (side length))
 
change x by ((-1) * (side length))
 
change y by (side length)
 
change y by (side length)
 +
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.
 
The chosen [[sprite]] will now draw a square when you run the block, starting with its original location as the top-right corner.
 
 
==Rectangle==
 
==Rectangle==
 
A rectangle is only slightly harder to draw. Use this block:
 
A rectangle is only slightly harder to draw. Use this block:

Revision as of 01:17, 20 January 2016

This tutorial will help you draw shapes using the pen using custom blocks.

Square

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

define square (side length)
repeat (4)
change x by (side length)
change y by ((-1) * (side length))
change x by ((-1) * (side length))
change y by (side length)
end

The chosen sprite will now draw a square when you run the block, starting with its original location as the top-right corner.

Rectangle

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

define rectangle height (height) width (width)
change x by (width)
change y by ((-1) * (height))
change x by ((-1) * (width))
change y by (height)

Your sprite will now draw a rectangle when you run the block, starting with the current location as the top right corner.

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.