public static void Vertical(FastBitmap bmp, Rectangle rect, PackedCol a, PackedCol b) { int x, y, width, height; if (!Drawer2DExt.ClampCoords(bmp, rect, out x, out y, out width, out height)) { return; } PackedCol c = a; for (int yy = 0; yy < height; yy++) { int * row = bmp.GetRowPtr(y + yy); float t = (float)yy / (height - 1); // so last row has b as its colour c.R = (byte)Utils.Lerp(a.R, b.R, t); c.G = (byte)Utils.Lerp(a.G, b.G, t); c.B = (byte)Utils.Lerp(a.B, b.B, t); int pixel = c.ToArgb(); for (int xx = 0; xx < width; xx++) { row[x + xx] = pixel; } } }
unsafe void CalculatePalette(int *palette) { for (int i = 0; i < Palette.Length; i++) { PackedCol col = Palette[i]; if (!Active) { col = PackedCol.Scale(col, 0.7f); } palette[i] = col.ToArgb(); } }
public static void Clear(FastBitmap bmp, Rectangle rect, PackedCol col) { int x, y, width, height; if (!ClampCoords(bmp, rect, out x, out y, out width, out height)) { return; } int pixel = col.ToArgb(); for (int yy = 0; yy < height; yy++) { int *row = bmp.GetRowPtr(y + yy); for (int xx = 0; xx < width; xx++) { row[x + xx] = pixel; } } }