Files
UwUGL/textures/hgradienttexture.cpp

28 lines
655 B
C++

#pragma once
#include <stdint.h>
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "texturebase.cpp"
namespace UwU {
class HGradientTexture : public TextureBase<HGradientTexture> {
public:
HGradientTexture(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);
}
};
}