The Pen Extension (Part 1)
CreatiCode last edited by info-creaticode
In the CreatiCode playground, you can draw on the stage directly, using the Pen extension. You first need to add that extension as shown below:
When we try to draw a line on paper, we take 3 steps:
- Put the pen down, so it touches the paper
- Move the pen while keeping the pen down
- Raise the pen up when we are done with the line
To draw on the stage using our sprite, you need to pretend it is a pen. Therefore, you need to use these 2 blocks to put down the pen and hold it up.
For example, to draw a line, we can put down the pen, move the sprite down a few steps, and then raise the pen up:
Note that the pen draws at the center point of the sprite, so the sprite may cover part of the drawing. You can fix that by hiding the sprite. In fact, even if you keep the sprite hidden all the time, it can still work as a pen.
To erase all the drawings on the stage, you can use the “erase all” block:
You can make the pen much thicker by changing its size. The tip of the pen is a circle, and the pen size is the diameter of this circle.
First, you can set the pen size directly using the “set pen size” block:
On the other hand, you can change the pen size relative to its current size, using the “change pen size” block. For example, we can increase the pen size by 10 each time we draw:
There are 3 ways to change the color of the pen.
- First, you can use the “set pen color to” block, which provides a color picker. Note that transparency works as well. In addition, if you do not move the sprite, the “pen down” block would still draw a big dot centered at the sprite.
- Secondly, you can use the “set pen <color/brightness/saturation/transparency> to” block, which allows you to set the value for these 4 properties directly.
- Lastly, you can use the “change pen <color/brightness/saturation/transparency> by” block, which allows you to change the value for these 4 properties relative to its current value.
Besides drawing with a pen, you can also use the sprite’s costume as a rubber stamp. When you run the “stamp” block, the sprite will draw itself on the stage.