Show similarity in app
This commit is contained in:
@@ -40,4 +40,6 @@ private:
|
||||
|
||||
Rectangle likedTextBox;
|
||||
Rectangle genTextBox;
|
||||
Rectangle simTextBox;
|
||||
float simil = 100.0f;
|
||||
};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "values/DnaManager.hpp"
|
||||
#include "values/Similarity.hpp"
|
||||
|
||||
namespace DnaStore
|
||||
{
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#define TOP (1 - pos)
|
||||
#define BOTTOM pos
|
||||
|
||||
Rectangle TextInSpace(Rectangle box, float textH, float textW, float margin, bool topOrBottom)
|
||||
Rectangle TextInSpace(Rectangle box, float textH, float textW, float margin, bool topOrBottom, bool leftOrRigth)
|
||||
{
|
||||
float br = box.width / box.height;
|
||||
float tr = textW / textH;
|
||||
@@ -42,8 +42,14 @@ Rectangle TextInSpace(Rectangle box, float textH, float textW, float margin, boo
|
||||
ret.y = box.y + box.height - hm - ret.height;
|
||||
}
|
||||
|
||||
ret.x = box.x + wm;
|
||||
|
||||
if (leftOrRigth)
|
||||
{
|
||||
ret.x = box.x + wm;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.x = box.x + box.width - wm - ret.width;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -68,6 +74,7 @@ void App::init(int screenWidth, int screenHeight)
|
||||
}
|
||||
|
||||
DnaStore::load(&manager);
|
||||
simil = Similarity::calc_similarity(manager.vector, Similarity::hamming_distance);
|
||||
upTex(Liked::tbd);
|
||||
while (!canvas.tick(canvasTexure[TOP]))
|
||||
{
|
||||
@@ -87,13 +94,19 @@ void App::init(int screenWidth, int screenHeight)
|
||||
0,
|
||||
(float)screenWidth / 2.0f,
|
||||
posY},
|
||||
20.0f, 83.0f, textMargin, false);
|
||||
20.0f, 83.0f, textMargin, false, true);
|
||||
|
||||
genTextBox = TextInSpace({0,
|
||||
posY + screenWidth,
|
||||
(float)screenWidth,
|
||||
posY},
|
||||
20.0f, 200.0f, textMargin, true);
|
||||
20.0f, 200.0f, textMargin, true, true);
|
||||
|
||||
simTextBox = TextInSpace({(float)screenWidth / 2.0f,
|
||||
likedTextBox.y,
|
||||
(float)screenWidth / 2.0f,
|
||||
likedTextBox.height},
|
||||
20.0f, 60.0f, textMargin, false, false);
|
||||
|
||||
destB = {0, posY, (float)screenWidth, (float)screenWidth};
|
||||
destA = destB;
|
||||
@@ -115,6 +128,7 @@ void App::upTex(Liked liked)
|
||||
DnaStore::saveGen(&manager);
|
||||
DnaManager::newGen(&manager);
|
||||
DnaStore::saveVec(&manager);
|
||||
simil = Similarity::calc_similarity(manager.vector, Similarity::hamming_distance);
|
||||
}
|
||||
DnaStore::saveData(&manager);
|
||||
}
|
||||
@@ -197,9 +211,10 @@ void App::draw()
|
||||
|
||||
DrawTexturePro(canvasTexure[TOP].texture, source, destA, origin, 360 - rotation, WHITE);
|
||||
|
||||
const char *text = TextFormat("GEN %d: %d / %d", manager.generation, unit[TOP].index + 1, NUM_PER_GEN);
|
||||
DrawText(text, genTextBox.x, genTextBox.y, genTextBox.height, BLACK);
|
||||
|
||||
const char *textGen = TextFormat("GEN %d: %d / %d", manager.generation, unit[TOP].index + 1, NUM_PER_GEN);
|
||||
DrawText(textGen, genTextBox.x, genTextBox.y, genTextBox.height, BLACK);
|
||||
const char *textProc = TextFormat("%.1f%%", simil);
|
||||
DrawText(textProc, simTextBox.x, simTextBox.y, simTextBox.height, BLACK);
|
||||
switch (topLiked)
|
||||
{
|
||||
case Liked::yes:
|
||||
|
Reference in New Issue
Block a user