Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.

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. This tutorial will show how to create a color palette. To follow this tutorial, the following are required:

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 would not work because it has saturation on its vertical axis instead of shade, and saturation is not 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 (PrtScn key).
  • Open an external paint program (ex. GIMP).
  • Paste the screenshot Ctrl or ⌘ Cmd then 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]
Note Note: "color" and "shade" in this script are variables because the palette is not what it is drawing.

Now, in the sprite that will be used 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 is 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

Cookies help us deliver our services. By using our services, you agree to our use of cookies.