Welcome back to my series on procedural content generation. Today we are going to learn how to play with color. Generating textures is great, but it's so much better when we can generate new color schemes to go with our textures. First, however, we need to do a little clean up.
We've built a lot of stuff so far. In part one we built some tools and noise. In part two we created patterns with sine waves, then mixed them with noise. However, so far our images are essentially black and white, or occasionally hard coded to a particular color like red. Today we're going to lerp through some colors. Don't worry, I'll explain that this means in a minute.
Now that we've got a little toolkit from part 1, let's draw a simple sin wave. As you may recall from your trigonometry, the sin function goes from -1 to 1. It also loops forever. That's going to be very handy.
Thanks to a project I'm doing at work I started reading a book on procedural content generation. ProcGen (as apparently the cool kids call it) is all about creating interesting systems with randomness, which inevitably brings up texture generation, which brings up Perlin Noise, one of the most useful sources of randomness.
I’ve used a lot of cross platform desktop toolkits over the years. I’ve even built some when I worked on Swing and JavaFX at Sun, and I continue development of Amino, an OpenGL toolkit for JavaScript. I know far more about toolkits than I wish. You would think the hardest part of making a good toolkit is the graphics or the widgets or the API. Nope. It’s deployment. Client side Java failed because of deployment. How to actually get the code running on the end user’s computer 100% reliably, no matter what system they have. Deployment on desktop is hard. Perhaps some web technology can help.
I’ve been using Node JS off and on for the past few years, ever since we used it in webOS, but I’ve really gotten to go deep recently. As part of my learning I’ve finally started digging into Streams, perhaps one of the coolest unknown features of Node.