bit of code cleanup
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "shader.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class ColorShader {
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
ColorShader(Color color) {
|
||||
this->shaderType = COLORSHADER;
|
||||
this->shaderColor = color;
|
||||
}
|
||||
ShaderType shaderType;
|
||||
Color shaderColor;
|
||||
|
||||
Color color(uint16_t u, uint16_t v) {
|
||||
(void)u;
|
||||
(void)v;
|
||||
return shaderColor;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "shader.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class HGradientShader{
|
||||
public:
|
||||
HGradientShader(uint16_t x0, Color color0, uint16_t x1, Color color1) {
|
||||
this->shaderType = HGRADIENTSHADER;
|
||||
this->x0 = x0;
|
||||
this->shaderColor0 = color0;
|
||||
this->scale = 0xffffffff / (1 + (uint32_t)x1 - (uint32_t)x0);
|
||||
this->shaderColor1 = color1;
|
||||
}
|
||||
ShaderType shaderType;
|
||||
uint16_t x0;
|
||||
Color shaderColor0;
|
||||
uint32_t scale;
|
||||
Color shaderColor1;
|
||||
|
||||
Color hGradient(uint16_t u, uint16_t v) {
|
||||
(void)v;
|
||||
uint32_t t = (((uint32_t)u - (uint32_t)x0) * scale) / 0x01000000;
|
||||
// if (v == 42) {
|
||||
// printf("(%u, %u)\n", u, t);
|
||||
// }
|
||||
return Helpers::lerpColor(shaderColor0, shaderColor1, (uint8_t)t);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
|
||||
namespace UwU {
|
||||
// shader prototype
|
||||
class Shader {
|
||||
public:
|
||||
//COLOR Shader
|
||||
Shader(Color color) {
|
||||
this->shaderType = COLOR;
|
||||
this->c0 = color;
|
||||
}
|
||||
|
||||
//HGRADIENT or VGRADIENT shader
|
||||
Shader(Direction direction, uint16_t uv0, uint16_t uv1, Color c0, Color c1) {
|
||||
this->c0 = c0;
|
||||
this->c1 = c1;
|
||||
switch (direction) {
|
||||
case H:
|
||||
shaderType = HGRADIENT;
|
||||
this->u0 = uv0;
|
||||
this->scale = 0xffffffff / (1 + (uint32_t)uv1 - (uint32_t)uv0);
|
||||
break;
|
||||
case V:
|
||||
shaderType = VGRADIENT;
|
||||
this->v0 = uv0;
|
||||
this->scale = 0xffffffff / (1 + (uint32_t)uv1 - (uint32_t)uv0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// BUFFER shader
|
||||
// Shader(uint16_t u, uint16_t v, Buffer buffer) {
|
||||
// this->shaderType = BUFFER;
|
||||
// this->u0 = u;
|
||||
// this->v0 = v;
|
||||
// }
|
||||
|
||||
ShaderType shaderType;
|
||||
uint16_t u0;
|
||||
uint16_t v0;
|
||||
Color c0;
|
||||
Color c1;
|
||||
uint32_t scale;
|
||||
};
|
||||
|
||||
class ShaderMethods {
|
||||
public:
|
||||
static Color gradient(uint16_t uv0, uint32_t scale, Color c0, Color c1, uint16_t uv) {
|
||||
uint32_t t = (((uint32_t)uv - (uint32_t)uv0) * scale) / 0x01000000;
|
||||
return Helpers::lerpColor(c0, c1, (uint8_t)t);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "shader.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class VGradientShader {
|
||||
public:
|
||||
VGradientShader(uint16_t y0, Color color0, uint16_t y1, Color color1) {
|
||||
this->shaderType = VGRADIENTSHADER;
|
||||
this->y0 = y0;
|
||||
this->shaderColor0 = color0;
|
||||
this->scale = 0xffffffff / (1 + (uint32_t)y1 - (uint32_t)y0);
|
||||
this->shaderColor1 = color1;
|
||||
}
|
||||
ShaderType shaderType;
|
||||
uint16_t y0;
|
||||
Color shaderColor0;
|
||||
uint32_t scale;
|
||||
Color shaderColor1;
|
||||
|
||||
Color vGradient(uint16_t u, uint16_t v) {
|
||||
(void)u;
|
||||
uint32_t t = (((uint32_t)v - (uint32_t)y0) * scale) / 0x01000000;
|
||||
// if (v == 42) {
|
||||
// printf("(%u, %u)\n", u, t);
|
||||
// }
|
||||
return Helpers::lerpColor(shaderColor0, shaderColor1, (uint8_t)t);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user