This tutorial explains how to create a drawing tool .
What is a drawing tool?
A drawing tool is something that is used to help people draw stuff, the one we are using can do several things.
What will this drawing tool do?
The drawing tool will be able to change the pen's size, color, saturation, brightness, and transparency.
What is needed?
First, 3 sprites and 2 backgrounds are needed. One sprite should be named "Draw Tool", another should be named "Color State", and the final sprite should be named "Pause State".
One background should be named "Paused" and the other should be "Unpaused". Both of the backgrounds should be blank.
We also will need to use the Pen Extension .
The Variables
Brightness:
Color:
paused?
Pen Size:
Pen Up?
Saturation:
Transparency:
Draw Tool Sprite
This is a small ball, just use "ball-c" from the Sprite Library .
Color State Sprite
This is just a big red square that is set at 0,0.
Please note that this sprite will not display the changes to the brightness.
Pause State Sprite
This sprite will show when the tool is paused.
The black bar is where the settings to change the drawing stuff will be.
The Code
We are going to start with the easiest part of the code.
Pause State Code
when clicked show go to x: 0 y: 0
when p: key pressed if paused? = yes then hide else show go to front: layer end
Color State Code
when clicked show go to x: 0 y: 0
when clicked forever set color: effect to Color: set brightness: effect to 100 - Saturation: set ghost: effect to Transparency: end
when p: key pressed if paused? = yes then hide else show end
Draw Tool Code
when clicked erase all switch backdrop to paused: set Pen Up?: to yes set Color: to 0 set Pen Size: to 50 set Saturation: to 100 set Brightness: to 100 set Transparency: to 0 set paused?: to yes go to x: 184 y: 129
when clicked forever if paused? = no then go to mouse-pointer: else set size to Pen Size: % set pen size to Pen Size: / 2.272727272727273 set pen color: to Color: set pen saturation: to Saturation: set pen brightness: to Brightness: set pen transparency: to Transparency: end
when s: key pressed if not paused? = yes then pen down set Pen Up?: to no else pen up set Pen Up?: to yes end
when p: key pressed if paused? = yes then hide variable Pen Size: hide variable Color: hide variable Saturation: hide variable Brightness: hide variable Transparency: switch backdrop to unpaused: set Paused?: to no else pen up set Pen Up?: to yes show variable Pen Size: show variable Color: show variable Saturation: show variable Brightness: show variable Transparency: switch backdrop to paused: set Paused?: to yes end
References