implemented shaders, gradients, and uv mapping
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "datatypes.cpp"
|
||||
#include "helpers.cpp"
|
||||
|
||||
namespace UwU {
|
||||
class Mapper {
|
||||
public:
|
||||
Mapper(Vec2 offset, Vec2 origin, Matrix4 transformation) {
|
||||
this->offset = offset;
|
||||
this->origin = origin;
|
||||
this->transformation = transformation;
|
||||
}
|
||||
Vec2 offset; // offset (translation)
|
||||
Vec2 origin; // origin (for rotation, etc)
|
||||
Matrix4 transformation; // transformation matrix (for rotation, translation, etc)
|
||||
|
||||
Coord2 map(Coord2 input) {
|
||||
int64_t x1 = (int64_t)transformation.xx * ((int64_t)input.x - (int64_t)origin.x);
|
||||
x1 += (int64_t)transformation.xy * ((int64_t)input.y - (int64_t)origin.y);
|
||||
x1 = x1 / 65536;
|
||||
x1 += origin.x;
|
||||
x1 += offset.x;
|
||||
int64_t y1 = (int64_t)transformation.yx * ((int64_t)input.x - (int64_t)origin.x);
|
||||
y1 += (int64_t)transformation.yy * ((int64_t)input.y - (int64_t)origin.y);
|
||||
y1 = y1 / 65536;
|
||||
y1 += origin.y;
|
||||
y1 += offset.y;
|
||||
return Coord2((uint16_t)x1, (uint16_t)y1);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user