Creating a Color Palette

A color palette is a screen region in which you select the desired color by clicking on it with the mouse. In the paint editor, it is the rectangular color selector at the bottom. A color palette can be created inside a project, mainly for selecting from a large amount of colors in drawing projects, with these simple steps. To follow this tutorial, you will need:

How to Create a Color Palette Sprite

To create a sprite used as a color palette, it is best to just use the palette that is implemented in the Scratch 1.4 paint editor. The Scratch 2.0 paint editor palette wouldn't work because it has saturation on its vertical axis instead of shade, and saturation isn't editable with the pen blocks. Perform these following steps:

  • Open the Scratch 1.4 paint editor.
  • Change the color palette to the advanced one with thousands of colors.
  • Take a screenshot ("print screen" key).
  • Open an external paint program (ex. GIMP).
  • Paste the screenshot (ctrl/cmd-v).
  • Drag a box around just the color palette.
  • Stretch the color palette horizontally so there are 200 pixels in width (since there are 200 pen hues).
  • Right click and select, "Copy To".
  • Import the image into Scratch as a new sprite.

Programming the Color Palette

Just like on the color palette, the pen blocks use a numbered value to represent a color. The pen blocks support 200 different hues and 100 shades. When programming this, the position of the mouse pointer, in relation to the palette, when a color is selected has to represent the hue and value. Before programming it, first take note that the hue at the very left of the palette is 0 and at the very right 199. The shade at the top of the color palette is 0 and the bottom 99. Since the mouse pointer's position is in relation to the palette, first make a comment of x position of the palette's very left end. Then add to that comment the y position of the very top of the palette. This is a representation of the script- the x position 100 and the y position 150. This script goes into the color palette sprite:

when this sprite clicked
set [color v] to ((mouse x) - (100))
set [shade v] to ([abs v] of ((mouse y) - (150)))
broadcast [set color v]
Warning Note: "color" and "shade" in this script are variables because the palette isn't what's drawing

Now, in the sprite that you will use for the drawing, implement this script:

when I receive [set color v]
set pen color to (color)
set pen shade to (shade)

Now the scripting is complete. How it works is the color palette sets color and shade variables when it's clicked, and then it triggers a script in the drawing sprite which sets the pen color and shade of itself to the previously set variables.

The only colors this script can not make are grays, as they require a third color value normally called saturation.

See Also

  • This page was last modified on 21 December 2016, at 20:13.