In minisphere 3.3, besides named colors, I combined the functions of
BlendColors() and
BlendColorsWeighted() into a single function:
Color.mix(). The function signature is:
Color.mix(color1, color2[, w1, w2]);
Calculates a weighted average of two colors. `w1` and `w2` are optional
and specify the relative weights of `color1` and `color2` respectively. If
the weights are omitted, the mix is 50/50.
This, combined with the new named colors and
Color#fade(), makes working with colors much easier:
TurnPreview.prototype.render = function()
{
var alpha = 255 * (1.0 - this.fadeness);
var y = -16 * this.fadeness;
SetClippingRectangle(0, y, 160, 16);
Rectangle(0, y, 48, 16, Color.Black.fade(alpha * 0.75));
OutlinedRectangle(0, y, 48, 16, Color.Black.fade(alpha * 0.125));
DrawTextEx(this.font, 24, y + 2, "next:", Color.Gray.fade(alpha), 1, 'center');
Rectangle(48, y, 112, 16, Color.Black.fade(alpha * 0.75));
OutlinedRectangle(48, y, 112, 16, Color.Black.fade(alpha * 0.125));
for (var id in this.entries) {
var entry = this.entries[id];
for (var i = 0; i < entry.turnBoxes.length; ++i) {
var turnBox = entry.turnBoxes[i];
var pictureColor = entry.color.fade(alpha);
Rectangle(turnBox.x, y, 16, 16, pictureColor);
OutlinedRectangle(turnBox.x, y, 16, 16, Color.Black.fade(alpha * 0.25));
DrawTextEx(this.font, turnBox.x + 4, y + 2, entry.name[0], Color.mix(entry.color, Color.White), 1);
}
}
SetClippingRectangle(0, 0, GetScreenWidth(), GetScreenHeight());
};
The code above was littered with
CreateColor() calls before and was harder to read as a result.