#include "src/main/cpp/util/vertexutil.h"
#define LOG_TAG "VertexUtil"
#define ELOGE(...) yyeva::ELog::get()->e(LOG_TAG, __VA_ARGS__)
float* VertexUtil::create(float width, float height, std::shared_ptr<PointRect> rect, float *array) {
if (array == nullptr) {
ELOGE("array is null");
return array;
}
array[0] = switchX(rect->x / width);
array[1] = switchY(rect->y / height);
array[2] = switchX(rect->x / width);
array[3] = switchY((rect->y + rect->h) / height);
array[4] = switchX((rect->x + rect->w) / width);
array[5] = switchY( rect->y / height);
array[6] = switchX((rect->x + rect->w) / width);
array[7] = switchY((rect->y + rect->h) / height);
return array;
}
float VertexUtil::switchX(float x) {
return x * 2 - 1;
}
float VertexUtil::switchY(float y) {
return ((y*2 - 2) * -1) - 1;
}