Build a Motion-Based Color Mixer and Palette

We’re going to build a color mixer that generates hues by mapping the orientation of an Android device relative to its x-, y-, and z-axes to the R, G, and B values of a color variable. We’ve already discussed the Processing color type in Using the Color Type. When the sketch is complete, as shown in the figure, you’ll be able to create every hue available to your device by rotating it in three-dimensional space.

In Erase a Palette with a Shake, we’ll add a feature that lets you erase the stored colors by shaking the device. The color mixer will help us to get a better sense of the Processing color type and the value ranges of the accelerometer motion sensor, and it will provide us with a good ...

Get Rapid Android Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.