28 lines
652 B
C++
28 lines
652 B
C++
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "../datatypes.cpp"
|
|
#include "../helpers.cpp"
|
|
#include "../buffer.cpp"
|
|
#include "texturebase.cpp"
|
|
|
|
namespace UwU {
|
|
class GradientTexture : public TextureBase<GradientTexture> {
|
|
public:
|
|
GradientTexture(uint16_t width, Color c0, Color c1) {
|
|
this->uScale = 0xffffffff / (1 + (uint32_t)width);
|
|
this->c0 = c0;
|
|
this->c1 = c1;
|
|
}
|
|
uint32_t uScale;
|
|
Color c0;
|
|
Color c1;
|
|
|
|
Color texel(uint16_t u, uint16_t v) {
|
|
(void)v;
|
|
uint32_t t = (((uint32_t)u) * uScale) / 0x01000000;
|
|
return Helpers::lerpColor(c0, c1, (uint8_t)t);
|
|
}
|
|
};
|
|
} |