Save a Color

images/Sensors/AccelerometerColorPicker.png

To save any color that we create by rotating our device about its three axes, we need a container that is good for storing color values. Processing provides us with the color type, which we looked at briefly in the previous chapter, Using the Color Type.

To implement the color picker, let’s rework our ​code​​​, and add a variable named swatch to store whatever color we pick when we tap the screen. We can then display the color pick value in an area at the bottom half of the screen, as shown here:

Let’s also display the individual values that correspond to the red, green, and blue variables as text using the red, green, and blue ...

Get Rapid Android Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.